0

I am trying to load javascript to a webview to change color of frame. I am getting "Blocked a frame with origin" error while javascript is being applied.

URL : https://checkout-testing.herokuapp.com/v3/hosted/pay/7f4d4fd48adde85420e3

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
        let changeHtmlbuttonScript = """
        document.getElementById(checkout).style.backgroundColor = "#0331FC"
        """
        webView.evaluateJavaScript(changeHtmlbuttonScript) { (success, error) in
            print("Error: \(error)")
        }
    }

I have tried setting "Arbitrary loads" property to false but no success. Does anyone know how to solve this.

aqsa arshad
  • 695
  • 6
  • 25
  • Does this answer your question? [SecurityError: Blocked a frame with origin from accessing a cross-origin frame](https://stackoverflow.com/questions/25098021/securityerror-blocked-a-frame-with-origin-from-accessing-a-cross-origin-frame) – Kiril S. Jul 22 '20 at 17:22
  • All that discussion is related to iframe not webview. I am not so sure if it all goes for webview as well. – aqsa arshad Jul 23 '20 at 06:30
  • well, there's no element with `id="checkout"`, but there's an element with `name="checkout"`, and it's an iframe. So yes, I think, this is the same problem - cross-origin feature. – Kiril S. Jul 23 '20 at 13:46

0 Answers0