IE8 Javascript document.domain 错误

发布于 2024-09-18 05:14:08 字数 452 浏览 3 评论 0原文

我需要更改文档的域,然后将其再次设置回原始值。

它看起来像这样[该页面位于域名base.site.com]:

function execute ()
{
document.domain = "site.com";

// Access an object that is on another frame, but did the same set of the domain

document.domain = "base.site.com";

// Access an object that is on this page (window.createPopup ())
}

问题是这在IE6上运行良好(我没有在7上进行测试)。 但当我执行第二个 document.domain 时,它给了我一个错误 [Invalid argument]。

有没有办法在IE8中“重置”文档的域?

I need to change the domain of the document and then set it back again to the original value.

It looks something like this [the page is on domain base.site.com]:

function execute ()
{
document.domain = "site.com";

// Access an object that is on another frame, but did the same set of the domain

document.domain = "base.site.com";

// Access an object that is on this page (window.createPopup ())
}

The problem is that this works fine on IE6 (I did not test on 7).
But it gives me an error [Invalid argument] when i execute the second document.domain.

Is there any way to "reset" the domain of the document in IE8?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

格子衫的從容 2024-09-25 05:14:08

问题是一旦将 document.domain 设置为仅顶级域,就无法将其设置为更严格的值。

来自 MSDN 博客:

简单地说,一旦放松了 document.domain,就无法再收紧它。

http ://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx

The problem is you cannot set document.domain to a more strict value once you set it to top-domain only.

From the MSDN blog:

Put simply, once you’ve loosened document.domain, you cannot tighten it.

http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx

聆听风音 2024-09-25 05:14:08

使用 text/cjs 类型的脚本标签:

<script type="text/cjs">
document.domain = '<your domain host value>';
</script>

Use script tag with type text/cjs:

<script type="text/cjs">
document.domain = '<your domain host value>';
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文