views:

345

answers:

3

I have a domain containing an iframe with contents from another domain. Inside this iframe are _top links. On IE6 nothing at all happens when you click them. I have prepared a minimal example of this. Please go to http://www.bemmu.com/static/top.html with IE6 to try it.

Edit: this only seems to happen if security level is "high" (or maybe custom), which it was by default in my IE on fresh install

Source of http://www.bemmu.com/static/top.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd"&gt;
<html>
    <body>
        <iframe src="http://bemmu4.appspot.com/static/iframe.html"/&gt;
    </body>
</html>

Source of http://bemmu4.appspot.com/static/iframe.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd"&gt;
<html>
    <body>
        <a href="http://www.google.com" target="_top">Let's go to Google!</a>
    </body>
</html>

Is there a way to get these _top links to work?

+2  A: 

I don't have ie6 installed in my machine, but I think you can try a little trick in iframe, setting an onclick attribute in your anchor tag with window.top.location.href='http://www.google.com';. Does it work?

GmonC
wow, you beat me by like 9 seconds :)
JasonWyatt
The same answer though you gave more explanation code. :) But when seconds turns out to minutes, nobody will see mine was the first.
GmonC
Well I looked at both equally :) And neither work. Well, I guess I can live without a solution, that high security mode on IE6 seems to be really strict, doesn't even allow document.write or alert()
Bemmu
Can you catch an exception by doing a try{CODE}catch(e){document.write(something)}? If so, maybe you can at least warn your users that it doesn't work in that security config.
GmonC
+1  A: 

Does it work for you to use something like this?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/DTD/strict.dtd"&gt;
<html>
    <body>
        <a href="http://www.google.com" target="_top" onclick="javascript:if(window.top){window.top.location='http://www.google.com';}"&gt;Let's go to Google!</a>
    </body>
</html>
JasonWyatt
Nice idea, but doesn't work. It did work directly from the page, but not when it was inside an iframe.
Bemmu
A: 

thanks, it works very well!

dumpling