title: GWT - "Access is Denied" JavaScript error when setting document.domain in Internet Explorer only
body: <p><strong>Background Information</strong></p>
  
  <p>I am working on a web application that utilizes GWT (v2.4). For the application, I am creating an iframe that will display some information from another website. I need to access some information from that iframe that is normally restricted via the Same Origin Policy (SOP). However, both sites (the parent and iframe) are hosted on the same super-domain, just under different sub-domains. So, something like this:</p>
  
  <ul>
  <li>Parent: dev.app.mySite.com </li>
  <li>frame: someOtherContent.mySite.com</li>
  </ul>
  
  <p>I know the usual solution for this problem is to set the property: document.domain = 'mySite.com' on both parent and iframe site to allow passage of SOP. This works for all browsers (that I'm concerned with) except Internet Explorer 8 (and probably other versions).</p>
  
  <p><strong>The Problem</strong></p>
  
  <p>In IE, when I attempt to load my web application, I get a completely blank page with the following JS exception, "Access is denied." The source of this problem is in GWT's myGwtAppName.nochache.js where GWT generates some code during the compilation process that it needs (see below).  </p>
  
  <p>From the research I've done on this problem in general, the root cause of this issue seems to be that in IE, unlike all other browsers, iframes <strong>don't</strong> inherit their parent's document.domain settings. From what I understand, the code generated by GWT runs in an iframe (based on this comment: <a href="https://stackoverflow.com/a/5161888">https://stackoverflow.com/a/5161888</a>). So, what I think is happening based on my limited knowledge of JS:</p>
  
  <ol>
  <li>I set document.domain = 'mySite.com' in the parent index page via JS and it is processed.</li>
  <li>myGwtAppName.nochache.js is processed.</li>
  <li>In nochache.js, code is ran to setup the GWT iframe sand-box environment</li>
  <li>In that code, a call is being made to a SOP restricted property of the sand-box iframe</li>
  <li>An exception is thrown because the site's parent document domain has been set to 'mySite.com' and the iframe's document.domain doesn't inherit that setting, so it's still 'dev.app.mySite.com'. This won't pass SOP because the domain has to be exactly the same.</li>
  </ol>
  
  <p><strong>The generated code that causes the exception</strong></p>
  
  <p>The below code, looks like it's setting up the GWT sandbox iframe environment.</p>
  
  <pre><code>var $intern_4 = 'myGwtAppName',
  $intern_7 = 'body',
  $intern_8 = 'iframe',
  $intern_9 = 'javascript:""',
  $intern_10 = 'position:absolute; width:0; height:0; border:none; left: -1000px; top: -1000px; !important',
  $intern_11 = '&lt;html&gt;&lt;head&gt;&lt;\/head&gt;&lt;body&gt;&lt;\/body&gt;&lt;\/html&gt;',
  $intern_12 = 'script',
  $intern_13 = 'javascript',
  $intern_14 = 'var $wnd = window.parent;''
  
  ....
  ....
  
  function setupInstallLocation(){
    if (frameDoc) {
      return;
    }
    var scriptFrame = $doc.createElement($intern_8);
    scriptFrame.src = $intern_9;
    scriptFrame.id = $intern_4;
    scriptFrame.style.cssText = $intern_10;
    scriptFrame.tabIndex = -1;
    $doc.body.appendChild(scriptFrame);
    frameDoc = scriptFrame.contentDocument;
    if (!frameDoc) {
      frameDoc = scriptFrame.contentWindow.document; //THIS CAUSES THE EXCEPTION
    }
    frameDoc.open();
    frameDoc.write($intern_11);
    frameDoc.close();
    var frameDocbody = frameDoc.getElementsByTagName($intern_7)[0];
    var script = frameDoc.createElement($intern_12);
    script.language = $intern_13;
    var temp = $intern_14;
    script.text = temp;
    frameDocbody.appendChild(script);
  }
  ....
  ....
  </code></pre>
  
  <p><strong>My Questions</strong></p>
  
  <ol>
  <li>Is my analysis of the situation completely off-base?</li>
  <li>Has anyone seen a solution for this problem that will work in a GWT environment in IE?</li>
  </ol>
  
  <p><strong>Information Sources</strong></p>
  
  <p>IE doesn't inherit document.domain settings: <a href="https://stackoverflow.com/a/1888711">https://stackoverflow.com/a/1888711</a> (and many other threads).</p>
  
  <p>GWT runs in an iframe sand-box environment: <a href="https://stackoverflow.com/a/5161888">https://stackoverflow.com/a/5161888</a></p>