WKWebView - iframe content is not loading in simulator/device

4.3k views Asked by At

I have a small app with WKWebView and HTML page in it. HTML page is loaded from http://localhost running on a small web server inside the iOS app.

The problem is... when I try to load content to the iframe in the page it won't load. Iframe is working when running the site in desktop web browser from any server (including server running in the iOS simulator or device). But in the WKWebView running in simulator or device content of the iframe is not shown. I can see the request from the WKWebView to the real url (my site with no iframe blocking headers and served over http or https).

Can't find anything about iframe content blocking when using WKWebView. JavaScript can do request to the same domain and load JSON data without any problem, but iframe won't show (or load?) content.

iframe code is like this and is inserted using JavaScript, but won't load even when I put this code directly to the html of the page.

<p><iframe src="https://example.com/wwVzepZ9ZXgSzVa4GA_sWw" width="320" height="50" class="feedAds" frameborder="1"></iframe></p>

Any help, please? I'm stuck with this for two days now.

1

There are 1 answers

1
Ladislav Soukup On

SORRY... I'm stupid, stupid stupid...

The whole problem was a "typo" in server response header for the page to be loaded inside the iframe...

Content-Type: Content-Type: text/html; charset=utf-8

Double "Content-Type:" - (invalid http header). WKWebView will not return any error or call any error callback, but will also leave the iframe empty.