IE8 Javascript document.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 ())
}
问题是这在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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是一旦将 document.domain 设置为仅顶级域,就无法将其设置为更严格的值。
来自 MSDN 博客:
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:
http://blogs.msdn.com/b/ie/archive/2008/09/02/ie8-security-part-vi-beta-2-update.aspx
使用
text/cjs
类型的脚本标签:Use script tag with type
text/cjs
: