SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 40
  1. #1
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Browser redirection script

    Hello

    I'm looking for a browser redirection script that will send you to another page if you're not using IE 5+ or Netscape 6. Does anyone know where I can find one?
    Sherice Jacob - Web Improvement Expert
    Improve Website Conversions | eBook Covers
    Follow Me on Twitter!

  2. #2
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have used this one from a1javavscripts, it may work for your situation.

    http://www.a1javascripts.com/redirec...rowsR/IE4.html


  3. #3
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh that's just what I was looking for, thank you!

    I had found one on HTML goodies, but it was reeeaaally old..from 1997..so this one is much better

    PS..love your avatar! We should make him into a smiley for the forums
    Sherice Jacob - Web Improvement Expert
    Improve Website Conversions | eBook Covers
    Follow Me on Twitter!

  4. #4
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hehe, you actually feel like your head is hurting if you stare at it long enuf! Or maybe im just a freak

  5. #5
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    But I'm not using IE 4...

    Well I tried it out, and it does exactly what I want it to..but (and I'm sure you knew this was coming...)

    It redirects me if I'm using IE 4 or 5 (and I'm not..I'm using 6). I want it to accept IE 5+ and Netscape 6+ but redirect all the other browsers. I'm no javascript genius, but here's the code I have:

    <Script><!-- A1 Javascripts-http://www.A1javascripts.com --><!--
    if (document.all) //IE4,5
    loc = 'content/update.html'
    else if (document.images) //NS3,IE4
    loc = 'content/update.html'
    else //NS2,IE3
    loc = 'content/update.html'
    window.location = loc;
    //--></Script>

    How can I fix it so that it redirects the other older browsers, but lets the page show normally for IE 5+ and Netscape 6+ users? :confused:

  6. #6
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's another script for checking versions:
    http://www.mozilla.org/docs/web-deve...wser_type.html

    This one checks for every browser known to man apparently.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  7. #7
    SitePoint Enthusiast RogueJedi's Avatar
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: But I'm not using IE 4...

    Internet Explorer 5 and above supports both the document.all collection and the document.getElementById method. The following should work for you:

    <script language="JavaScript" type="text/javascript">
    if(document.all) {
    // Do something for IE4
    }
    else if(document.all && document.getElementById) {
    //Do something for IE5+
    }
    else if(document.layers) {
    //do something for NS4.x
    }
    else if(document.getElementById && !document.all) {
    //Do something for NS6+
    }
    else {
    //Do something for everyone else
    }
    </script>
    Rob Nolan
    Do or do not, there is no try.

  8. #8
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would this one work?

    <HEAD>
    <SCRIPT language="JavaScript">
    <!--
    var browserVer=parseInt(navigator.appVersion);
    if (browserVer >= 5)
    {
    window.location="http://www.someplace.com/v4.html";
    }
    else
    {
    window.location="http://www.someplace.com/other.html";
    }
    //-->
    </SCRIPT>
    </HEAD>

    redirecting users with Netscape 4.x and below and IE 4 and below to another page?
    Sherice Jacob - Web Improvement Expert
    Improve Website Conversions | eBook Covers
    Follow Me on Twitter!

  9. #9
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Sparkie,

    Yes, it should work, though you might also catch some newer browsers (mozilla, opera) whose versions are 4 or lower.

    RogueJedi's script is better because it checks for function/capability. M$ or AOL may come out with a new browser version 1 and your script would have to be rewritten. With Rogue's script, you only need to rewrite it when you begin using 'new, improved' features.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  10. #10
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I dont see anything in RogueJedi's script that lets me redirect users to another page if they dont use 5+ browsers..?

  11. #11
    SitePoint Enthusiast RogueJedi's Avatar
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That would be because I did not put the code for redirection into the example I gave. I left that as an excercise for the reader.
    Rob Nolan
    Do or do not, there is no try.

  12. #12
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmmmmmm.. like this?

    <script language="JavaScript" type="text/javascript">
    if(document.all) {
    // Do something for IE4
    }
    window.location="http://www.someplace.com/1.html";
    else if(document.all && document.getElementById) {
    //Do something for IE5+
    }
    window.location="http://www.someplace.com/2.html";
    else if(document.layers) {
    //do something for NS4.x
    }
    window.location="http://www.someplace.com/3.html";
    else if(document.getElementById && !document.all) {
    window.location="http://www.someplace.com/other.html";
    //Do something for NS6+
    }
    else {
    window.location="http://www.someplace.com/4.html";
    //Do something for everyone else
    }
    </script>
    Last edited by Sparkie; Oct 28, 2001 at 20:14.

  13. #13
    SitePoint Enthusiast RogueJedi's Avatar
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes. Just make sure the necessary code is *inside* the curly braces...

    [ ... ]
    if(document.all) {
    // Do something for IE4
    }
    window.location="http://www.someplace.com/1.html";
    [ ... ]
    Rob Nolan
    Do or do not, there is no try.

  14. #14
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I keep getting syntax errors. Can you show me exactly how it should be written?

    Here is exactly what I have:

    <script language="JavaScript" type="text/javascript">
    if(document.all) {
    // Do something for IE4
    }
    window.location="http://www.someplace.com/1.html";
    else if(document.all && document.getElementById) {
    //Do something for IE5+
    }
    window.location="http://www.someplace.com/2.html";
    else if(document.layers) {
    //do something for NS4.x
    }
    window.location="http://www.someplace.com/3.html";
    else if(document.getElementById && !document.all) {
    window.location="http://www.someplace.com/other.html";
    //Do something for NS6+
    }
    else {
    window.location="http://www.someplace.com/4.html";
    //Do something for everyone else
    }
    </script>

    I also have another javascript on that page that kills the netscape window-resize but that makes it crash..maybe those two scripts aren't getting along..
    Last edited by Sparkie; Oct 30, 2001 at 10:08.

  15. #15
    SitePoint Enthusiast RogueJedi's Avatar
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're putting your redirect code outside of the if blocks. Try this instead:
    Code:
    <script language="JavaScript" type="text/javascript"> 
    if(document.all && document.getElementById) { 
    //Do something for IE5+ 
    window.location="http://www.someplace.com/2.html"; 
    } 
    else if(document.all) { 
    // Do something for IE4 
    window.location="http://www.someplace.com/1.html"; 
    } 
    else if(document.layers) { 
    //do something for NS4.x 
    window.location="http://www.someplace.com/3.html"; 
    } 
    else if(document.getElementById && !document.all) { 
    window.location="http://www.someplace.com/other.html"; 
    //Do something for NS6+ 
    } 
    else { 
    window.location="http://www.someplace.com/4.html"; 
    //Do something for everyone else 
    } 
    </script>
    Rob Nolan
    Do or do not, there is no try.

  16. #16
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you very much Rob! Your help has been unbelievably appreciated

  17. #17
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm. Seems I've spoken too soon!

    Now the pages just keep trying to load over and over again!

  18. #18
    SitePoint Enthusiast RogueJedi's Avatar
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I replied to your PM.
    Rob Nolan
    Do or do not, there is no try.

  19. #19
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I still dont understand what the problem could be (I PMmed you again). If on my index.html page, I have the script set to redirect you to an update page if you're using an outdated browser, and on to the index.html page if you're using the right browser...that wouldn't work for each html page (if you're using the correct filename for each one)?

  20. #20
    SitePoint Enthusiast
    Join Date
    Jul 2001
    Location
    East Side
    Posts
    98
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you are using Dreamweaver, there is an extension you can download from the Macromedia site that will do this for you with only a few clicks!

  21. #21
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mmmkay, I copied the script to the index.html file, and I have it set to redirect users to index.html if they have the right browser..and update.html if they do not.

    But the problem is that the script keeps repeating itself..what should I do?

  22. #22
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi sparkie,

    Could you post a url (it might save time

    1) what exactly does your code look like?
    2) where are you calling it from?
    3) where is it located?
    4) are the locations correctly spelled (case counts)?
    5) which browser is giving you the problem?
    6) are any of the browsers redirecting to the same page? that is, are you saying something like:

    if (document.all) window.location=thispage where thispage is the index page? if so, you shouldn't. You do not need to redirect browsers that are ok, only those that are not ok. The only case in which you would redirect everyone is if the 'index.html' page does only one thing -- redirect.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  23. #23
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh! I'll try that out..thats probably what was causing the problem (redirecting the latest browsers)

    Thanks so much Vincent!

  24. #24
    Skills to Pay the Bills Sparkie's Avatar
    Join Date
    Jul 1999
    Location
    A cave with 47 computers and an internet feed
    Posts
    3,559
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Whaaaa?

    I've got the following code in there now:
    <script language="JavaScript" type="text/javascript">
    if(document.all && document.getElementById) {
    // Do something for IE4
    window.location="http://www.collegetec.com/intstudies/content/update.html";
    }
    else if(document.layers) {
    //do something for NS4.x
    window.location="http://www.collegetec.com/intstudies/content/update.html";
    }
    else {
    window.location="http://www.collegetec.com/intstudies/content/.html";
    //Do something for everyone else
    }
    </script>
    I'm using IE 6..but it redirects me anyway! What's up with that?

  25. #25
    SitePoint Enthusiast RogueJedi's Avatar
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's because your test is for IE5+, not for IE4. To test for IE4 just use if(document.all).
    Rob Nolan
    Do or do not, there is no try.


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
  •