Execute javascript on WKWebView

Hi, im tryign to execute a javascript line inside of the loaded page on a wkwebview, the line is “document.body.style.backgroundColor = ‘#212121’;”. That line will chang the background color of the page.

 

this is what i tried, its on the ViewDidLoad

 

        chatWebView.evaluateJavaScript(“document.body.style.backgroundColor = ‘#212121’;”, completionHandler: nil)

 

they recomended me to add the UIWebViewDelegate but this is wkwebview, and use the webViewDidFinishLoad.

 

How should i do?

Powered by WPeMatico

About

You may also like...

Comments are closed.