简体   繁体   中英

Get the current URL of Cocoa's WebView

Im new to Cocoa.

I'm trying to extract the URL of the currently loaded webpage in my WebView object. I use this WebView to show a login screen and after logging in I have to get some parts of the URL.

I have already tried

[[[[frame provisionalDataSource] request] URL] absoluteString];

but this one only works one time, when called while loading. If the loading is complete it returns "(null)". The problem is, that it seems like the URL changes while loading the page so i get the wrong URL.

Does anybody know how to get the URL at any time I want?

Thanks

Switch provisionalDataSource with dataSource . Once the frame starts loading, it's not provisional anymore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM