Internet Explorer:除非状态码为200,否则无法访问IFrame内容 [英] Internet Explorer: Can't Access IFrame Contents Unless Status Code is 200

查看:163
本文介绍了Internet Explorer:除非状态码为200,否则无法访问IFrame内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于IE不支持异步文件上传,我正在使用一种解决方法,将表单发布到iframe。我绑定iframe的onLoad事件,并在事件触发时读取它的内容。除非服务器返回200以外的状态码,否则IE8 / IE9会抛出SCRIPT5:Access is denied错误。看起来微软已经决定不应该允许任何人阅读iframe的内容,除非请求返回200 OK。



谷歌搜索没有任何结果,所以我在这里寻求帮助。任何人都可以重现这种奇怪的行为吗?反正有这个问题吗?



iframe不违反任何跨站点安全策略。它们都在同一个域中。

解决方案

我想我在尝试在小提琴手上重现问题时已经完成了这一项工作。在IE中关闭显示友好的HTTP错误消息似乎解决了这个问题。我无法在fiddler上重现它的原因是他们的404页面超过了512字节,因此无论如何它都会显示nginx错误。基本上,整个问题是当一个页面小于512字节(或者在某些情况下为256)时,IE似乎用整个页面替代,这会导致以编程方式阻止对该页面的访问。显然,微软的监督似乎仍然存在于IE10中。

很容易复制。只需将以下内容放置在服务器下的文件(例如test.html)中,然后返回512字节以下的404响应代码,并确保您的IE设置为显示友好的错误消息(还要确保test1.file实际上并不实际存在)。在IE打开开发者控制台的情况下打开页面,你会看到访问被拒绝的错误。如何刷新页面会改变结果。 CTRL + F5似乎不会出现问题,但CTRL + R或F5会。

 <!DOCTYPE HTML> 
< html lang =en>
< head>
< / head>
< body>
< script type =text / javascript>
iframe = document.createElement('iframe')
iframe.src ='/test1.file'
document.body.appendChild(iframe)
iframe.contentDocument
< / script>
< / body>
< / html>

现在,如果我能找到我可以提交IE10的错误报告的地方,那么我们可以让我们的生活处理这个可怕的浏览器只是更好一点。


Because IE doesn't support Asynchronous file uploads, I'm using a work-around that involves posting a form to an iframe. I bind the the onLoad event of the iframe and read its contents when the event is fired. This works well, except when the server returns a status code other than 200, in which case IE8/IE9 throws a "SCRIPT5: Access is denied" error. It seems Microsoft have decided that no one should be allowed to read the contents of an iframe unless the request returns 200 OK.

Googling has turned up nothing, so here I am seeking help. Can anyone else reproduce this odd behavior? Is there anyway around this issue?

The iframe does not violate any cross-site security policies. It's all on the same domain.

解决方案

I think I've worked this one out while trying to reproduce the problem on fiddler. Turning off the "Show Friendly HTTP error messages" in IE seems to fix it. The reason I couldn't reproduce it on fiddler is that their 404 pages are over 512 bytes, hence it would show the nginx error regardless.

Basically, the whole issue is that when a page is less than 512 bytes (or 256 in some cases), IE seems to substitute the whole page which has the consequence of blocking access to that page programmatically. Obviously an oversight by Microsoft which still seems to be present in IE10.

It's easy to reproduce. Just place the following in a file (e.g. test.html) under a server than returns a 404 response code under 512 bytes, and ensure your IE is set to show friendly error messages (also make sure "test1.file" doesn't actually exist). Hit the page with IE with the developer console open, and you should see a "access denied" error. How you refresh the page alters the outcome. A CTRL+F5 doesn't seem to exhibit the problem, but a CTRL+R or F5 does.

<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<script type="text/javascript">
iframe = document.createElement('iframe')
iframe.src = '/test1.file'
document.body.appendChild(iframe )
iframe.contentDocument
</script>
</body>
</html>

Now, if only I could find where I can submit bug reports for IE10 so we can make our life dealing with this horrific browser just a little better.

这篇关于Internet Explorer:除非状态码为200,否则无法访问IFrame内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆