Note that there are some explanatory texts on larger screens.

plurals
  1. PODocument.domain and <iframe>s breaks the "Back" button in Internet Explorer
    text
    copied!<p>This is a very urgent problem and I'd be forever indebted to anyone who can lend some insight.</p> <p>I'm going to be deploying a widget (called the "ISM") to a third-party site. That site uses the document.domain JavaScript property to relax cross-domain restrictions (e.g., setting document.domain in "a.example.com" and "b.example.com" to both "example.com" so they can access each other's DOMs).</p> <p>This causes problems with my script in Internet Explorer due to the way that I construct an &lt;iframe&gt; that is used to display my widget's HTML content. In Internet Explorer, using document.domain on a page, and then creating an &lt;iframe&gt; with JavaScript, will cause you to be immediately "locked out" of the &lt;iframe&gt; - i.e., you can create it, but it's not created in the correct document.domain, so you're not able to access its DOM due to security restrictions. This isn't a problem in any other browser.</p> <p>To see what I'm talking about, load this page in IE:</p> <p><a href="http://troy.onespot.com/static/3263/stage1.html" rel="nofollow noreferrer">http://troy.onespot.com/static/3263/stage1.html</a></p> <p>You should see a JavaScript error: "Access is denied."</p> <p>To get around this, I'm setting the dynamically created &lt;iframe&gt;'s "src" attribute to load a static HTML file that's hosted in the same domain (different subdomain), and setting its document.domain property to the appropriate value:</p> <p><a href="http://troy.onespot.com/static/3263/stage2.html" rel="nofollow noreferrer">http://troy.onespot.com/static/3263/stage2.html</a></p> <p>That gets around the security issue, and lets me write the document I originally wanted to write to the &lt;iframe&gt;:</p> <p><a href="http://troy.onespot.com/static/3263/stage3.html" rel="nofollow noreferrer">http://troy.onespot.com/static/3263/stage3.html</a></p> <p>With that document in place, my widget does some polling to our server to get some HTML content that I want to insert into another &lt;iframe&gt;, which will be visible to visitors of the parent page. I've roughly simulated that here (using static content, not actually contacting our server):</p> <p><a href="http://troy.onespot.com/static/3263/stage4.html" rel="nofollow noreferrer">http://troy.onespot.com/static/3263/stage4.html</a></p> <p>Here comes the problem. When I get that HTML content and insert it into the second &lt;iframe&gt;, I now face an unusual issue with a broken "Back" button. This happens in Firefox 3.0 and all version of IE (possibly other browsers), though it does not happen in some browsers I've tested (Firefox 3.5, Safari, Chrome). See this page:</p> <p><a href="http://troy.onespot.com/static/3263/stage5.html" rel="nofollow noreferrer">http://troy.onespot.com/static/3263/stage5.html</a></p> <p>If you click the "Google" link, all seems fine. But, when navigating back to the previous page (that has the latter test script), another JavaScript error is introduced: "Permission denied." This does not terminate the script, and does not appear to have any ill effects, other than the fact that I assume it's connected to the broken "Back" button functionality, which is a very big problem - the one I'm desperately trying to solve. I'm at a loss to debug this error since its call stack starts and stops in the jQuery script.</p> <p>You can also encounter this error - with more serious symptoms - by going to the last link above (stage5.html - clear your browser cache first). Click the "Stage 5 (Again)" link, then, after that page has loaded, click the "Back" button.</p> <p>The "Back" button is completely broken! You can't go anywhere except to another URL.</p> <p>This is the problem that I need to solve as soon as possible. Any insights or help would be <em>extremely</em> appreciated!</p> <p>I can't deviate from this method too much, so outside-the-box suggestions are definitely welcome, but I may not be able to use them due to the constraints of the widget's specifications. I would prefer to understand why the "Back" button is breaking and how to fix it, along with the "Permission denied" error related to jQuery.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload