Updating the address bar with the current URL from UIWebview

As an iPhone Safari browser, I want to update UItextviewwith the current urlUIWebView

I tried the delegate method shouldStartLoadWithRequest, but in the end I got the url of some ads / iframe

If I use the delegate method webViewDidFinishLoad, then the address bar is updated at the end of the request.

Please help me in the best approach.

+3
source share
2 answers

You want to use the method mainDocumentURLin NSURLRequest's webView:shouldStartLoadWithRequest:. This should contain the URL of the main document, regardless of whether the page is loading or the resource is loading on the page (for example, a frame).

+5
source

webviewDidFinishLoad -, [ webview stringByEvaluatingJavaScriptFromString:@"document.title"] weboutWebView.request.URL.absoluteString URL-.

0

Source: https://habr.com/ru/post/1772762/


All Articles