SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2002
    Location
    San Diego, CA
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Redirect not working?

    I'm back for more help. :-)

    I have a Javascript redirect on pages inside my site (not the index page) because Netscape 4+ doesn't see the CSS properly. I'd tested it at home, and it worked fine. But now testing it on another computer, its not redirecting.

    If you'd like to check for yourself on Netscape 4.7, test this page:
    http://www.exiesuniverse.com/news.html

    The script in question is:

    <SCRIPT language="JavaScript">
    version=parseInt(navigator.appVersion);
    if (navigator.appVersion.indexOf('5.')>-1){version=5};
    if (navigator.appVersion.indexOf('6.')>-1){version=6}; browser='OTHER';
    if (navigator.appName=='Netscape'){browser='NS'+version;}
    if (navigator.appName=='Microsoft Internet Explorer'){browser='MSIE'+version;}
    if (navigator.appVersion.indexOf('MSIE 3')>0) {browser='MSIE3';} if(browser == 'NS5'){browser='NS6'};
    if (browser=='MSIE3') {window.location='http://www.exiesuniverse.com/badBrowser.html'}
    if (browser=='MSIE4') {window.location='http://www.exiesuniverse.com/badBrowser.html'}
    if (browser=='NS3') {window.location='http://www.exiesuniverse.com/badBrowser.html'}
    if (browser=='NS4') {window.location='http://www.exiesuniverse.com/badBrowser.html'}
    </script>

    located in the head of my page. Unfortunately I don't remember where I got the script. I only want to redirect Netscape 4.7 and older (and old MSIE), other versions work fine.

    As always, thanks for any help.

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    alert(browser);

    Just above the first if (browser)

    You can then see where it's going after that.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2002
    Location
    San Diego, CA
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually I can't. Sorry, I don't know Javascript (yet). I just cut & paste from several of the "free javascripts" sites, and usually it works.

    Also, I have tested this on a few more computers, and sometimes it redirects, sometimes it doesn't. Could it be the settings in the browser itself?

  4. #4
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I doubt it.

    That would mean some browsers have JS turned off, which
    isn't really all that likely.

    SCRIPT language="JavaScript">
    version=parseInt(navigator.appVersion);
    if (navigator.appVersion.indexOf('5.')>-1){version=5};
    if (navigator.appVersion.indexOf('6.')>-1){version=6}; browser='OTHER';
    if (navigator.appName=='Netscape'){browser='NS'+version;}
    if (navigator.appName=='Microsoft Internet Explorer'){browser='MSIE'+version;}
    if (navigator.appVersion.indexOf('MSIE 3')>0) {browser='MSIE3';} if(browser == 'NS5'){browser='NS6'};
    alert(browser);
    if (browser=='MSIE3') {window.location='http://www.exiesuniverse.com/badBrowser.html'}
    if (browser=='MSIE4') {window.location='http://www.exiesuniverse.com/badBrowser.html'}
    if (browser=='NS3') {window.location='http://www.exiesuniverse.com/badBrowser.html'}
    if (browser=='NS4') {window.location='http://www.exiesuniverse.com/badBrowser.html'}
    </script>


    Hope this gives you more info as to what it thinks it's doing.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •