Results 1 to 4 of 4

Thread: current browser detect redirect script help

  1. #1
    Join Date
    Apr 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default current browser detect redirect script help

    I have:
    www.mywebsite.com/index.html for Safari (my main browser type)
    www.mywebsite.com/index2.html for MS Internet Explorer
    www.mywebsite.com/index3.html for Mozilla/FireFox/Netscape

    can anyone help me with a (current ver compat.) browser detect then redirect script for the corresponding pages? The weak ones I've found on the net are at least 3 or 4 years old on average and are worthless.

    Will the follwoing work in my <head> how do I make it compatable with all versions? version=="all" will that work and will the script work at all itself?
    thanks

    <SCRIPT>
    browser = navigator.appName
    ver = navigator.appVersion
    version = ver.substring(0,1)
    if (browser=="Safari") {
    if (version=="All")
    document.location.href="www.mywebsite.com/index.html"
    }
    if (browser=="Internet Explorer") {
    if (version=="All")
    document.location.href="www.mywebsite.com/index3.html"
    }
    if (browser=="Netscape") {
    if (version=="All")
    document.location.href="www.mywebsite.com/index3.html"
    }
    if (browser=="Firefox") {
    if (version=="All")
    document.location.href="www.mywebsite.com/index2.html"
    }
    if (browser=="Mozilla") {
    if (version=="All")
    document.location.href="www.mywebsite.com/index2.html"
    }
    </SCRIPT>

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by brent13a
    I have:
    www.mywebsite.com/index.html for Safari (my main browser type)
    www.mywebsite.com/index2.html for MS Internet Explorer
    www.mywebsite.com/index3.html for Mozilla/FireFox/Netscape
    Do you mind if I ask why? I sincerely doubt that is necessary, and you're potentially creating a lot of work for yourself when it comes to maintenance. Moreover, what about the user agents you appear not to have considered, such as Opera or Konqueror?

    can anyone help me with a (current ver compat.) browser detect
    Browser detection is flawed and unreliable. User agents regularly misrepresent themselves to ensure that users of the software aren't discriminated against.

    Browser detection should be avoided in scripting. It is generally more important to know what is supported by any particular host, rather than what that host is. The only exception is when countering known bugs that cannot be examined via feature detection, or some other direct means. However, that is rare and I've never had to do it.

    Mike

  3. #3
    Join Date
    Apr 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well, it's really stupid: I primarily use Safari and I build my website using a mac osx program. So on my homepage background is grey BUT on all the different browsers its rendered a slightly different grey. I also have a java applet for my front page with a background; what rgb code works for safari is too dark for IE and what rgb code works for firefox/mozilla/netscape is too dark for safari. Thats my problem: very slight cross-browser incompatablility or whatever. Hence 3 different front pages.....or four if someone were to help me with a javascript and thro in a line for Opera (I believe Safari uses Konq. in it's base).

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by brent13a
    Well, it's really stupid: I primarily use Safari and I build my website using a mac osx program. So on my homepage background is grey BUT on all the different browsers its rendered a slightly different grey.
    Creating several different documents is not a workable solution, and I really can't see any justification for something so trivial as minor colour differences. Choosing a colour that is acceptable, but not identical, across various platforms is.

    If this colour thing is centered around this applet of yours, you are probably better off deliberately choosing a different colour that works with the rest of the colour scheme.

    Mike

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
  •