How to enable javascript for a web view app in iOS?

Hi I'm having a issue enabling javascript for a app that I'm developing that is basicly a webview.

Can anyone please help?

Kind Regards

Replies

What platform are you working on? What web view are you using? [Last I checked there were four web views on our platforms, two of which are available on macOS (WKWebView and WebView) and three on iOS (SFSafariViewController, WKWebView and UIWebView).]

In general web views always have JavaScript enabled; you shouldn’t need to explicitly enable it. How are you testing this?

I tried this myself with following sequence:

  1. I pointed a simple WKWebView-based iOS app at http://www.w3schools.com/js/default.asp.

  2. Once the page loaded, I tapped Click me to display Date and Time

  3. The date and time showed up as expected.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Will that enabled JS be parsed from a remote server and or will it be local/in the app bundle?

Hi thanks for the answer, tested with the link you sent and it worked fine.

but using the link that I'm going to use all javascript doesn't work. Going to continue to test might it be the version of the JS?

but using the link that I'm going to use all javascript doesn't work. Going to continue to test might it be the version of the JS?

I doubt that this is related to how you loaded the JavaScript; it seems much more likely that this is just a bug in your JavaScript. iOS provides some neat-o features for debugging JavaScript using the Web Inspector on your Mac. There’s a bunch of info about this in the Safari Web Inspector Guide.

Note That document references UIWebView, but the same technique works for WKWebView.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"