I created a iOS web browser with swift language code. And add an extra button to inject a script on that web page, but it always crash when I try this:
webView!.evaluateJavaScript("document.body.style.background = 'red';", nil)
Any idea how to fix this? And how to read the JavaScript code from a file, and then inject it to that webview element.
I use the code style as this example but with WKWebView: https://github.com/rshankras/WebViewDemo
If you can solve this question I need a basic working code in the answer. And solution for how to load the JavaScript from a file. And inject that code in the WKWebView element.
See Question&Answers more detail:os