Cross-browser iframe url replace

Discussion in 'JavaScript' started by baka, Jun 25, 2008.

  1. #1
    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?
     
    baka, Jun 25, 2008 IP
  2. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #2
    docment.getElementById only retrieves the reference to an object that has 'id' property not just 'name', e.g.

    Give it a try and let me know results.

    regards
     
    Vooler, Jun 26, 2008 IP