Friday, October 9, 2026
HomeiOS Developmentios - WKWebView swift Javascript allow

ios – WKWebView swift Javascript allow

[ad_1]

I’m utilizing WKWebView to load some hyperlinks in my software. I need to allow all JavaScript banners that seem on most internet pages. At the moment once I open the WebView I can not manipulate the button within the webView.

I attempted to allow all javascript like under code nevertheless it nonetheless not working.

My present configuration is IOS 14, I need it to work on all profiles

func setupWebView() {
        let configuration = WKWebViewConfiguration()
        configuration.allowsInlineMediaPlayback = true
        if #accessible(iOS 14.0, *) {
            let webPageDefaultPrefs = WKWebpagePreferences()
            webPageDefaultPrefs.allowsContentJavaScript = true
            configuration.defaultWebpagePreferences = webPageDefaultPrefs
        } else {
            let preferences = WKPreferences()
            preferences.javaScriptEnabled = true
            configuration.preferences = preferences
        }
        let webView = WKWebView(body: .zero, configuration: configuration)
        self.webView = webView
    }

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments