Document.domain and <iframe> s break back button in Internet Explorer

This is a very urgent problem, and I will be forever indebted to anyone who can give some idea.

I am going to deploy a widget (called "ISM") on a third-party site. This site uses the JavaScript property document.domain to ease cross-domain restrictions (for example, setting document.domain to "a.example.com" and "b.example.com" on both "example.com" so that they can access each other DOM).

This causes problems with my script in Internet Explorer due to the way I create an <iframe> which is used to display the contents of my HTML widget. In Internet Explorer, use document.domain on the page, and then create an <iframe> with JavaScript, will make you immediately "block" from <iframe> - i.e. you can create it, but it is not created in the correct document.domain, so you cannot access its DOM due to security restrictions. This is not a problem in any other browser.

To find out what I'm talking about, download this page in IE:

http://troy.onespot.com/static/3263/stage1.html

You should see a JavaScript error: "Access denied."

To get around this, I set the dynamically created <iframe> src attribute to load a static HTML file hosted in the same domain (another subobject) and set its document.domain property to the appropriate value:

http://troy.onespot.com/static/3263/stage2.html

This concerns the security issue and allows me to write the document that I originally wanted to write in the <iframe>:

http://troy.onespot.com/static/3263/stage3.html

With this document, my widget does some polling on our server to get some HTML content that I want to embed in another <iframe> that will be visible to visitors to the parent page. I roughly imitated this here (using static content, without actually contacting our server):

http://troy.onespot.com/static/3263/stage4.html

That is the problem. When I get this HTML content and paste it into the second <iframe>, now I am facing an unusual problem with a broken back button. This happens in Firefox 3.0 and in the entire version of IE (possibly in other browsers), although this does not happen in some browsers that I tested (Firefox 3.5, Safari, Chrome). See this page:

http://troy.onespot.com/static/3263/stage5.html

If you click on the Google link, everything seems fine. But when you go to the previous page (which has the last test script), another JavaScript error is introduced: "Permission denied". This does not terminate the script, and apparently does not have any negative consequences, besides the fact that I assume that it is connected with the broken functionality of the back button, which is a very big problem - one that I am desperately trying to solve . I find it difficult to debug this error since its call stack starts and stops in a jQuery script.

You may also encounter this error - with more serious symptoms - by going to the last link above (stage5.html - clear your browser cache first). Click the "Step 5 (again)" link, then, after loading this page, click the "Back" button.

The back button is completely broken! You cannot go anywhere other than another URL.

This is a problem that I need to solve as soon as possible. Any ideas or help would be greatly appreciated!

I cannot deviate too much from this method, so outside suggestions are certainly welcome, but I may not be able to use them due to limitations of the widget specifications. I would rather understand why the back button breaks down and how to fix it, along with the "Resolve reject" error associated with jQuery.

+4
source share
2 answers

It is very difficult to try fixes for this due to several domains. One thing I heard is that IE treats empty src or "about: blank" as another domain, but it treats "javascript:" "" as the same domain. You experimented with modifying the first step to install iframe src in things like:

iframe.src = 'javascript:""' 

Or:

 iframe.src = 'javascript:parent.getFrameHTML()' 
+3
source

Part of the problem is that IE (at least IE 7) adds two entries to the history with the name "Domain" when I click the "Scene 5 again" link. When you use the small drop-down arrow next to the back button, you will see a page history that allows you to step back more than one step. I see that the previous two entries are listed as β€œDomain”, and clicking any of them leads me to the same page. The fourth place (after the current page, domain, domain) is the correct "Back to ISM" link to the stage5.html source page.

Thus, the problem is not that the "Back" button does not work, but that records in the history have just been added, and therefore the "Back" button will lead you to the wrong place. I have no answer why these "Domain" entries are added to the history, but I hope this helps you in a useful direction.

Good luck

+1
source

All Articles