IE8 Javascript document.domain error
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 obj开发者_如何学JAVAect 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?
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
Use script tag with type text/cjs
:
<script type="text/cjs">
document.domain = '<your domain host value>';
</script>
精彩评论