Javascript Embedded In Html Not Running In Wkwebview
I am implementing wkwebview in an app that was using UIWebView. I am unable to get javascript to execute when pointing to a local html file that has the javascript embedded within
Solution 1:
You should be calling your javascript in this WKNavigationDelegate
method, which is called when the webview finishes loading.
public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
webView.evaluateJavaScript("initMap()", completionHandler: { (value, err) in
// Handle response here.
})
}
Also, I'm not sure why you're calling two different webview.load()
requests - maybe don't do that?
Post a Comment for "Javascript Embedded In Html Not Running In Wkwebview"