Blank iFrame in IE

2019-01-06 23:23发布

I have an iframe:

<iframe src="http://externaldomain.com/something.html">

If something.html from externaldomain.com has the css:

html { position: relative; }

In IE, it will render the iframe as blank. All other browser are fine.

Anyone know of a solution? Remember the same origin policy. I cannot alter anything within the iframe with javascript or change the css as the iframe src is external.

Thanks.

4条回答
等我变得足够好
2楼-- · 2019-01-06 23:50

Use the following syntax it will work.

Give the style="position:relative;" to your iframe it will work in IE.

查看更多
唯我独甜
3楼-- · 2019-01-06 23:56

iframe must have attribute ID

window.parent.document.getElementById('iframeid').contentWindow.document.execCommand('print', false, null);
查看更多
在下西门庆
4楼-- · 2019-01-06 23:58

I would start by reading this Another Cross Domain iFrame Communication Technique and then look at a more elegant AJAX solution. I have seen a lot of situations where cross-domain iframes just don't work (and for good reason).

IFrames are one step above IE in the Axis of Evil (IMO)

查看更多
贪生不怕死
5楼-- · 2019-01-07 00:05

As a workaround, if all else fails, you can download the contents of something.html using server-side logic, like ASP.NET or PHP, and save it on your local web-server somewhere. Then you can avoid the same-origin policy, or you can even modify the HTML/CSS yourself on the server, for ex., remove the offending position:relative.

查看更多
登录 后发表回答