Document.domain "resolved" problems with IE8

I'm currently trying to load a page inside a subdomain into my main domain using an iframe, and call the javascript function (when dom-ready) in my main domain so that the main domain can resize the iframe to fit the height of the content. Here is an example

www.mysite.com (code inside the page):

<script type="text/javascript">
document.domain = "mysite.com";
function doSomething() {
    //do something
}
</script>
<iframe id="mytestid" src="test.mysite.com" height="0" width="900"></iframe>

And for my other site, test.mysite.com, here is the code inside the page:

<script>
document.domain = "mysite.com";

$(document).ready(function () {
    window.parent.doSomething();
});
</script>

This seems to be great for firefox, safari and chrome, but not for IE8. When making a callwindow.parent.doSomething()

IE8 always gives me an error

I could not test IE7 or IE6 to find out if the problem persists, but has anyone encountered this problem? Am I missing something with the way I set out the code?

Thanks for helping the guys.

+5
3

document.domain " " IE8 SOLVED!!

, - document.domain, iframe , iframe.

SRC iframe, , document.domain IE8, .

+2

:

, , IE. , - , .

, , :

  • , IE , . (iframes ..), (main iframe)
  • - . setTimeout , document.domain
+1

, - .

Since I had a different site with similar settings, where everything worked fine, I opened both windows side by side and noticed in the status bar below that it was under the "Local Intranet" and the other was under the "Trusted Sites".

This led me to another point of verification: make sure that both subdomains are displayed in the same Security Zone in IE Internet Security Properties! If they do not, you will have an error with permission to refuse.

+1
source

All Articles