SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast newsomer's Avatar
    Join Date
    Oct 2001
    Location
    Southwestern Georgia, USA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    getElementById and Netscape 7

    Please Note: I am not in any way trying to start a browser war here, just trying to find out why something does not work, I want to know if it is faulty scripting.

    Why does the following not work in Netscape 7?

    Having three files: index.htm, iframe_a.htm, and iframe_b.htm (see details below). The following behaviors occur:

    Netscape 7.0

    • Button A: Only works if Radio Button B was the previously selected control
    • Button B: Never works except if Radio Button B was the previously selected control it puts the contents of iframe_a.htm into the iframe
    • Radio Button A: Only works if Radio Button B was the previously selected control
    • Radio Button B: Always works unless Hyperlink B was the previously selected control
    • Hyperlink A: Never works
    • Hyperlink B: Never works
    • Refresh (Ctrl-R): Does not put iframe_a.htm into the iframe if it contains iframe_b.htm at refresh but iframe_a.htm shows at page open

    MSIE 6.0

    • All buttons and refresh work as expected
    If my scripting is correct I guess I'll just use the radio buttons but would much rather use the form buttons or hyperlinks.

    Thanks.


    index.htm contains the following HTML and script:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>Iframe</title>
    <script>
    function changeContent(strSrc) {
     document.getElementById("iframe01").src = strSrc;
    }
    </script>
    </head>
    <body>
    <div style="text-align:center;">
    <form>
    <button onClick="changeContent('iframe_a.htm');">A</button>&nbsp;&nbsp;
    <button onClick="changeContent('iframe_b.htm');">B</button><br />
    <input type="radio" onClick="changeContent('iframe_a.htm');" />A&nbsp;&nbsp;
    <input type="radio" onClick="changeContent('iframe_b.htm');" />B<br />
    <a href="javascript:void(0);" onClick="changeContent('iframe_a.htm');">A</a>&nbsp;&nbsp;
    <a href="javascript:void(0);" onClick="changeContent('iframe_b.htm');">B</a>
    </form>
    <iframe width="380" height="80" frameBorder="1" marginheight="0" marginwidth="0" id="iframe01" src="iframe_a.htm" scrolling="no">
    </iframe>
    </div>
    </body>
    </html>
    iframe_a.htm and iframe_b.htm contain identifyably different content for testing purposes.
    There are three types of people.
    Those that can count and
    those that cannot.

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Your links don't work in NS because you don't have "return false;" after you call your function in the onclick handler, executing "void(0);".

  3. #3
    SitePoint Addict
    Join Date
    Dec 2002
    Posts
    386
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    those spaces between java and script might not be helping either

  4. #4
    SitePoint Enthusiast newsomer's Avatar
    Join Date
    Oct 2001
    Location
    Southwestern Georgia, USA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks vgarcia. I finally figured it out, onclick="return [function()]". Works great now.

  5. #5
    SitePoint Enthusiast newsomer's Avatar
    Join Date
    Oct 2001
    Location
    Southwestern Georgia, USA
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pissant
    those spaces between java and script might not be helping either
    I noticed those after I posted the quesition. Not in my code must have been put there when I posted it to the forum.

    Thanks anyway.
    There are three types of people.
    Those that can count and
    those that cannot.


Bookmarks

Posting Permissions

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