Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cross-browser iframe url replace

    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?

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    it will work for ie5.5+, firefox1+ and opera8+. But better use the parent reference:
    Code:
    parent.document.getElementById('iframe1').contentWindow.location.href
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    As I said, should work in all the modern browsers, on Windows, MAC, Linux...
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •