Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WKWebView local file in iframe

I've an WKWebView whose load a local html file named 'start.html'. Inside this file, i load an other local document in iframe.

But i'm not allowed to use js from start.html on iframe content and iframe content not allowed to load js file.

Before WKWebView i've use UIWebView but i'm forced to migrate to improve performance

In UIWebView i never had any problems with the crossdomain security.

When i add attribute sandbox='allow-same-origin' on iframe, i can successfully execute js code from start.html like this

$("#frame")[0].contentWindow.document.getElementsByClassName('password_field')[0].value = password_field

but js code and http requests inside iframe (file loaded in iframe is a js player) is not allowed to run, i get theses errors :

Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.

What is the difference between UIWebVIew and WKWebView. Is there a solution to allow js code and http requests inside iframe ?

like image 284
Khorwin Avatar asked Nov 09 '22 19:11

Khorwin


1 Answers

WKWebView is only allowed to read local content stored in the directory provided by NSTemporaryDirectory().

Please see my answer here for more details.

like image 71
Thomas Elliot Avatar answered Nov 15 '22 04:11

Thomas Elliot