...

View Full Version : Cross-browser iframe url replace



baka
06-25-2008, 09:00 AM
Hi. I have two iframe's in a page. I need to click a button in iframe1 and redirect the iframe2 to another page. I have found this code but I'm not sure if it's compatible with older browsers. I checked a few references but I couldn't find anything regarding iframes. Here's the code:

<input type=button onclick="top.document.getElementById('iframe1').contentWindow.location.href='page2.htm'">

I need it at least work with ie5.5+, firefox1+ and opera8+. What do you think?

Kor
06-25-2008, 01:29 PM
it will work for ie5.5+, firefox1+ and opera8+. But better use the parent reference:


parent.document.getElementById('iframe1').contentWindow.location.href

baka
06-26-2008, 08:07 AM
Thanks a lot for the help.

I forgot to add one more thing. What about Mac browsers? I don't have a Mac of any way to try this on a Mac, any ideas about this code being compatible with Mac browsers?

Kor
06-26-2008, 08:26 AM
As I said, should work in all the modern browsers, on Windows, MAC, Linux...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum