"访问被拒绝"在访问iframe的文档对象错误

人气:470 发布:2022-09-11 标签: javascript ajax iframe

问题描述

有关张贴AJAX的形式有许多参数的形式,我使用创造了一个解决方案的 IFRAME ,发帖的形式,它通过邮寄,然后访问 IFRAME 的内容。 具体而言,我访问这样的内容:

For posting AJAX forms in a form with many parameters, I am using a solution of creating an iframe, posting the form to it by POST, and then accessing the iframe's content. specifically, I am accessing the content like this:

$("some_iframe_id").get(0).contentWindow.document

我测试了它和它的工作。

I tested it and it worked.

在某些页面,我开始收到访问被拒绝的错误。据我所知,如果IFRAME是从同一个域提供这不应该发生。

On some of the pages, I started getting an "Access is denied" error. As far as I know, this shouldn't happen if the iframe is served from the same domain.

我是pretty的肯定是工作之前。任何人有一个线索?

I'm pretty sure it was working before. Anybody have a clue?

如果我不是足够清楚:我张贴到的同一个域的。因此,这不是一个跨域请求。我测试的IE浏览器而已。

If I'm not being clear enough: I'm posting to the same domain. So this is not a cross-domain request. I am testing on IE only.

P.S。我不能用简单的ajax POST查询(不要问...)

P.S. I can't use simple ajax POST queries (don't ask...)

推荐答案

由我自己解决吧!

但问题是,即使正确的响应发送(验证与小提琴手),它被发送的HTTP 500错误code(而不是200)。

The problem was, that even though the correct response was being sent (verified with Fiddler), it was being sent with an HTTP 500 error code (instead of 200).

所以,事实证明,如果一个响应发送一个错误code,IE浏览器取代了 IFRAME 的从磁盘加载的错误信息内容( RES://ieframe.dll/http_500.htm ),并导致该跨域访问被拒绝的错误

So it turns out, that if a response is sent with an error code, IE replaces the content of the iframe with an error message loaded from the disk (res://ieframe.dll/http_500.htm), and that causes the cross-domain access denied error.

385