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 6 of 6
  1. #1
    New Coder
    Join Date
    Mar 2004
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JS Browser Detection and Redirect not working in NS4?

    Hello again,

    I am using a Javascript redirect to (I think) take users of 4.x browsers and redirect them to a separate page than users of higher-version browsers. I can't seem to get NS 4.79 (which, as I mentioned in my other thread toady, I have to support for some dumb reason) to go the appropriate page (todayinhistoryjava.html). I feel kind of dumb asking this, but because it's 4.70 and not plain old 4.0, does the below JS not quality NS 4.79 as a version 4 browser? If so, how should I modify my code to get the redirect to trap all users of 4.x browsers between versions 4.0 and 5.0?

    Here is the code:

    <html>
    <head>
    <SCRIPT language="JavaScript">
    <!--
    var browserVer=parseInt(navigator.appVersion);
    if (browserVer >= 4)
    {
    window.location="mainpage.html";
    }
    else
    {
    window.location="todayinhistoryjava.html";
    }
    //-->
    </SCRIPT>

    </head>
    <body>

    Thanks!

    Amanda

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi:

    if (document.layers) {

    }

    shortcut


    -james
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #3
    New Coder
    Join Date
    Mar 2004
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi James,

    Wouldn't this redirect ALL Netscape users to my "todayinhistoryjava.html" page? Or would it only redirect users whose Netscape version supports STRICTLY layers? (Not sure what version Netscape started supporting iframes....)

  • #4
    New Coder
    Join Date
    Mar 2004
    Posts
    32
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nevermind - tested it and it works great! Thanks!

  • #5
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wouldn't this redirect ALL Netscape users to my "todayinhistoryjava.html" page? Or would it only redirect users whose Netscape version supports STRICTLY layers? (Not sure what version Netscape started supporting iframes....)


    Hi:

    Sorry it took me so long to respond....

    Yeah, I use it myself on my own site. I'm not aware of any problems with doing this. NS6 & IE6+ are DOM browsers...they should all use document.getElementByID. Anyway, I don't keep up with the DOM stuff, 'cause i always code for backwards compatibility...to me, this means, if it works in NN & IE 4, it will work in newer versions as well.. at least, I haven't encountered any problems yet...

    Glad it worked for you.



    -james
    Last edited by jamescover; 07-10-2004 at 12:01 AM.
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #6
    Regular Coder Vincent Puglia's Avatar
    Join Date
    Jul 2003
    Location
    where the World once stood
    Posts
    367
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Hi 007,

    As james showed you, you should always test for browser features rather than what is written in the navigator object

    if you ever have to test for all browsers, this is the order to do it in -- unless you specifically intend to cripple IE5+ and group it in with IE4

    if (document.getElementById)
    {
    \\ all version 5+ browsers (including IE5+, which uses document.all)
    }
    else if(document.all)
    {
    \\ ie4 only
    }
    else if (document.layers)
    {
    \\ nn4 only
    }
    else
    {
    non-div/layering browsers -- version (-4)
    }


    Vinny
    Where the world once stood
    the blades of grass
    cut me still


  •  

    Posting Permissions

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