Get current URL of UIWebView

后端 未结 14 1942
天命终不由人
天命终不由人 2020-11-29 16:08

I already tried getting the current URL of my UIWebView with: webview.request.URL. Unfortunately the NSURL was empty. Anything wrong h

相关标签:
14条回答
  • 2020-11-29 16:49

    I use the shouldStartLoadWithRequest event (UIWebViewDelegate) to catch URL updates. request.mainDocumentURL.absoluteString will get you the main web page's URL (which is normally what you want), while request.URL.absoluteString will include CSS and JavaScript includes.

    0 讨论(0)
  • 2020-11-29 16:53

    As UIWebView is deprecated, for WKWebview to get the current url is very simple.

    webView.url
    
    0 讨论(0)
提交回复
热议问题