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 3 of 3
  1. #1
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    818
    Thanks
    43
    Thanked 6 Times in 5 Posts

    switching a frame on loadup

    Hi. I have a frameset with three frames: called top, middle and bottom.

    The contents of the bottom frame only work properly in the Explorer browser, so I have an alternative frame with contents that work fine in Netscape.

    What I would like is to use javascript to check which browser is loading the frameset and choose the appropriate bottom frame to load.

    From my experiments it seems the code should reside between the <head> tags in the bottom frame itself, not the frames page HTML (true?).

    I have:

    <script language="JavaScript">
    //-->
    function netscape4() {

    var whoAmI = navigator.appName;
    var whatAmI = parseInt(navigator.appVersion.charAt(0));

    if (whoAmI == "Netscape" && whatAmI == 4) {
    top.frames['bottom'].location=(netscapesafe.html');
    }

    }
    // End -->
    </script>

    <body onload="netscape4()">

    I assume it is the ......... top.frames['bottom'].location=(netscapesafe.html'); .......... line which is not working, but I've tried every combination of javascript words known to man, and no swopping in of the correct frame.

    What am I doing wrong?

    Thanks

    Terry

  • #2
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    I'm not so good with framesets, but I noticed a missing apostrophe in that line you think might be causing the problem. I don't think the parentheses matter, but I guess it won't hurt to keep them.

    top.frames['bottom'].location=(netscapesafe.html');

    should be

    top.frames['bottom'].location=('netscapesafe.html');

  • #3
    Regular Coder tpeck's Avatar
    Join Date
    Oct 2002
    Location
    Sydney, Australia
    Posts
    818
    Thanks
    43
    Thanked 6 Times in 5 Posts
    Thanks so much arnyinc,

    I think the missing apostrophe was only in my posting, but GUESS WHAT? I have solved my own problem!

    I should have been using:

    self.location('netscapesafe.html');

    I discovered it by accident just by trying out all the combinations of javascript words (it took about 3 days...)

    I think this is really useful - it means I can switch in a version of page or a frame that is specific for a browser (when you just CAN"T get something to render properly).

    OK - the full working code for a frame or page that is compatible with, say, Netscape 4 is:

    **********************************

    <script language="JavaScript">
    //-->
    function netscape4() {

    var whoAmI = navigator.appName;
    var whatAmI = parseInt(navigator.appVersion.charAt(0));

    if (whoAmI == "Netscape" && whatAmI == 4) {
    self.location=('netscapesafe.html');
    }

    }
    // End -->
    </script>

    <body onload="netscape4()">

    **********************************

    Place it on the page or frame that won't render properly in Netscape 4 and the 'netscape4.html' page/frame will load into it!

    SOLVED!

    Terry


  •  

    Posting Permissions

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