Internet Explorer 7 blocks cross-domain iframe to parent communication
March 17, 2008
Most Popular | Elearning | Javascript | Questionmark Perception | Web Building

A new security setting in Microsoft Internet Explorer 7 has been causing problems with requests between iframe and parent. There is a security setting in the Internet options called "Navigate sub-frames across different domains", which in IE6 was set to "Enabled" under Medium security, but is set to "Disabled" in IE7 by default.

An example of the type of communication that is blocked is shown here:

The container page sends a message to Page 1, in Domain A: "Change your location to Page 2". In IE6, this is not a problem. But in IE 7, it is allowed.

Ads by Google

Posted by ellen at March 17, 2008 06:53 PM

According to Microsoft:

This option controls whether readers of a Web page can navigate the sub-frame of a window with a top-level document that resides in a different domain. This option has the following settings:
  • Disable, which allows users to navigate only between Web page sub-frames that reside in the same domain.
  • Enable, which allows users to navigate between all Web page sub-frames, regardless of the domain, without being prompted.
  • Prompt, which prompts users to choose whether to navigate between Web page sub-frames that reside in different domains.


This new setting causes problems for a lot of sites that use communication across domains.

Sites that use a page in one domain to display the data, where the authentication is handled by a site in a different domain, displayed in an iframe would be affected. Many ajax sites use "fragment identifiers" for communication across domains.

According to the Tagneto blog:

A page is served from a different domain than the URL for an iframe in that page. Normally cross domain, cross frame communication is prohibited for security reasons. However, the two frames can communicate with each other by using fragment identifiers (the hash part of an URL, like"

A site that I run uses cross iframe/cross-domain communication to launch and track a quizzing application which runs on one server from within an elearning application in another domain. I may have a partial solution to this issue.

My site is located in Domain "A". Several pages within the site contain quizzes embedded in iframes. the quizzing application is located in Domain B.

The final page of each quiz transmits the user's score back to the main site by communicating up the frame tree to the parent page of the iframe, and across domains.

Normally, clicking the final "Transmit Score" link at the end of the quiz sends a URL like this:

to the parent page of the iframe. The parent page receives the score and max score at the end and processes that information as required. What happens in IE7, though, is that the browser ignores the targeting to the parent page and opens the requested URL in a new window. This breaks communication because the new window is not in the correct spot in the frame tree.

My solution is, instead of communicating directly up to the parent page from Domain B, to instead redirect the Domain B page to a "redirector" page in Domain A. Then use THAT page to relay the data up the frame tree, to the parent page in Domain A. (Fortunately navigating between two pages in the same domain is still legal!)

All the redirector page contains is some javascript that parses the URL and sends it on up to the correct page:


//this provides a function to parse the query string for various parameters.
var qsParm = new Array();
function qs(){
var query =;
var parms = query.split('&');
for (var i=0; i<parms.length; i++) {
var pos = parms[i].indexOf('=');
if (pos > 0) {
var key = parms[i].substring(0,pos);
var val = parms[i].substring(pos+1);
qsParm[key] = val;
}//end if
}//end for
}//end function

qsParm['home'] = null;
if (qsParm['home'] != null ){ parent.location.href=qsParm['home']+"&Max="+qsParm['Max']; }
else alert("some kind of warning goes here");

Ads by Google



Excellent post,It saved my day.
I was experimenting with lot of complex javascript code to Refresh the Parent page from a cross domain Iframe. But your idea helped me simplify my task.


thanks Chandra. Also your comment made me realize I'd left out the closing PRE tag on the final snippet of url-parsing code at the end. Not necessary to the cross-domain solution, but might be helpful to somone

This may help but need instruction.
I want to insert an image to a page on another domain, I have no idea how to parse img url as query string to the new page, please help.

code on my domain. url in code will be a window on another domain, how can I rewrite my code and the new window to make it work?

<body onload=function(){document.getElementById("place_holder").src =document.getElementById("imgurl").value;} >
function ResizeThem() {
maxwidth= 250;
for (p=0; p<imgs.length; p++) {
if (imgs[p].getAttribute("alt")=="user posted image") {
if (parseInt(imgs[p].width)>maxwidth) {
imgs[p].setAttribute('alt','Reduced Image - Click to see full size');
imgs[p].onclick=new Function("document.getElementById('imgurl').value = this.src;'','ImageViewer','resizable=1,scrollbars=1');iw.focus()");
if (parseInt(imgs[p].height)>maxheight) {
imgs[p].onclick=new Function("document.getElementById('imgurl').value = this.src;'','ImageViewer','resizable=1,scrollbars=1');iw.focus()");

<input type="hidden" id="imgurl">

OK, so if I understand what you want, the clickable images are on a page in which is displayed within an iframe on a page in

You want to click an image on the page and have it be inserted somewhere on the page.

You will need to create a "redirector page" in Let's call it redirector.htm. It contains the function qs() which can parse the parameters in a query string and turn them into variables that you can use.

So if the person clicks an image on page, make that click generate this link:

When redirector loads within the iframe, it will run qs() and parse out "imgurl", "imgattribute2", "imgattribute3", etc. You can define variables like:
var imageURL=qsParm['imgurl']
var imageAttr2 = qsParm['imgattribute2']

Then build a new URL from those variables and have the parent document refresh itself to the same URL, but including those parameters.

Then run qs() on that document and parse the url again and do something with the parameters.

Hi - I have a page on domain-A with two IFrames. One frame comes from domain-B, and has links meant to target the second frame, whose content can come from domain-A.

I'm attempting to use your workaround for the IE7 problem. My coding knowledge might be far less then it needs to be for this, but here's what I did:

1) Created 'redirectTest.html' and pasted the above script into the body of the page.
2) In the domain-B frame I created a link similar to the one you outlined in your most recent post:

Obviously that link is written wrong. Did I also create the script page incorrectly? Any help would be appreciated. Thanks

Hi, please see the demo I just uploaded.

download zip of the files here:

it shows 2 iframes on a page communicating using this method.

I understand about the coding info above. However, I'm not the web designer on a site I'm having an issue with. Is there a way to install a hotfix or something to rectify this problem in MS Explorer 7? Please send me an email and let me know. Thanks so much.


Just add the site to your trusted sites, or change the setting described in the first paragraph for your medium security sites.

This may be unrelated but, from an iframe I want to have the parent page change while the page running in the iframe stays the same. I want our customers to be able to scroll to the item they want- then click the hyperlink and they be taken to a page describing the clicked item while the contents in the iframe remains. Instead when I click on the link inside the iframe, the frame changes to a full page and the parent page stays!

Rick, you can easily test if it is the same issue by changing the security setting in the Internet options called "Navigate sub-frames across different domains" to "Enabled." If the problem goes away, it's the same issue. Sounds like it is though.

your way of approach is precious.thank u for ur kind guidens.
this code open the .doc files inside the iframe well in the System that has msword2003. but it open the file in seperate browser with system that has msword2007. do u have any suggestion to this. plz kindly send me

Hai i m having two IFrames in a webpage
First Iframe has a DropDownList
Second IFrame has a textbox
Whenever i change the item in tehe dropdownlist of First Iframe the selected items's text should be displayed in the Second IFrame's TExtBox

How can i do this? From morning i m struggling with this issue please reply

hello all
how i can hide the div of domainB inside iframe of domainA ?

I am working on the same issue as `hello all
how i can hide the div of domainB inside iframe of domainA ?`

I appreciate any help, if I have solution I will post it here.

Thank you so much! You saved my life!

I removed the action for the else condition and it works perfectly!

*praise praise


plz clarify me whether doing CORS by using url fragment technique (proxyfying/ see my demo at url below) is different than you redirection technique?

If both of them are different then what are their pros and cons and which one should be preferably used.

my demo:

Ads by Google

 RSS   |   Contact Me

Ads by Google