似乎android的WebViewClient有这样的方法:onProgressChanged((
有什么关于ios的wkwebview吗?(或任何其他 iOS 网页视图(
Webview的onNavigationStateChange
在这里似乎没有帮助。
想在www.example.com
上评估JS,然后在www.example.com/about
上评估JS。
你说onNavigationStateChange
到底是什么意思?这听起来并不熟悉。
您应该实现 WKNavigationDelegate。[https://developer.apple.com/documentation/webkit/wknavigationdelegate]。
如果要在加载 url 后加载 JS,可以实现webView(_, didFinish: WKNavigation)
。WKNavigation提供了用于检查请求/URL的API。
要在导航完成之前加载一些 JS,您可以尝试使用webView(WKWebView, decidePolicyFor: WKNavigationAction)
[https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview]
或webView(WKWebView, decidePolicyFor: WKNavigationResponse)
[https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview]。
参见 WKUserScript,它是专门为此而设计的。创建 WKWebView 时,您将添加一个 WKUserContentController,该控制器可以使用addUserScript
添加脚本。