开发者

Periodic "access is denied" when trying to open an iframe to write content

开发者 https://www.devze.com 2023-01-23 04:56 出处:网络
We have an \"access is denied\" javascript error occurring on a couple of clients every day (we 开发者_开发技巧are notified via webservice call whenever an unhandled js error occurs).The error happens

We have an "access is denied" javascript error occurring on a couple of clients every day (we 开发者_开发技巧are notified via webservice call whenever an unhandled js error occurs). The error happens on .04% of page requests so it is by no means common nor has it been reproducible by us.

The error has been observed on IE6, IE7, and IE8 so it appears to be an IE issue.

Here is the simplified markup and associated javascript that is causing the problem:

Markup

<iframe id="frm" src="javascript:false;" />

JS

var frm = document.getElementById("frm");
var frmDoc = frm.contentWindow.document;
frmDoc.open();
frmDoc.write('some html');

The "access is denied" error occurs when we call frmDoc.open().

After searching the internet for any clue to what might cause this, the only hope I have is that someone might have a valid hypotheses concerning what might be going on. Maybe this is an IE bug, but if there is a way to work around it we would like to pursue it.

All wild ideas are welcome.


One possible reason: The javascript-protocol is disabled/unknown in IE(maybe forced by some security-software).

I made a test, renamed inside the registry the javascript-protocol, so that IE cannot handle it(the URL of the iframe) and got the same error-message.

Try using about:blank instead of javascript:false;

0

精彩评论

暂无评论...
验证码 换一张
取 消