Lior Z
Lior Z

Reputation: 668

Disable Javascript in UIWebView

My iOS app needs to display very basic HTML received from a third party (using loadHTMLString with nil as baseURL).

Using a UIWebView was simple enough, however - I have a security concern since this view can also run Javascript, which is not allowed and also unnecessary for my app.

Is there a way to disable the app from running javascript? If not - does anyone know of a good sanitizing code to remove any malicious stuff (yet keep the regular HTML) from an NSString?

Thanks, Lior

Upvotes: 3

Views: 2741

Answers (1)

Igor
Igor

Reputation: 1557

have you tried to use WKWebView it have the configuration option where you can set

javaScriptEnabled = NO;

https://developer.apple.com/library/ios/documentation/WebKit/Reference/WKPreferences_Ref/index.html#//apple_ref/occ/instp/WKPreferences/javaScriptEnabled

Upvotes: 2

Related Questions