How do you test what broswer a person is using on a web site?

Sharky Forums


Results 1 to 10 of 10

Thread: How do you test what broswer a person is using on a web site?

  1. #1
    Reef Shark Pestilence's Avatar
    Join Date
    Dec 2000
    Location
    Hickville, USA. :(
    Posts
    353

    Post How do you test what broswer a person is using on a web site?

    I'm the webmaster for a student organization and I want to be able to test what broswer a person uses and then what version it is so that I could then make a direction page that says whether or not their version is too old to be properly viewed with my web site.

    ------------------
    Kill em all and let God sort'em out.
    God damnit, better graphics != revolutionary gaming! Get it through your skull!

  2. #2
    Great White Shark
    Join Date
    Nov 2000
    Location
    Alpharetta, Denial, Only certain songs.
    Posts
    9,925

    Post

    Check out the source code in the following page. It does a browser test.

    http://home.netscape.com/download/index.html?cp=djuc1

    ------------------
    "I'd kill for you, Marge. Please ask me to kill for you." -Homer Simpson

    Crusader for the 64-bit Era.
    New Rule: 2GB per core, minimum.

    Intel i7-9700K | Asrock Z390 Phantom Gaming ITX | Samsung 970 Evo 2TB SSD
    64GB DDR4-2666 Samsung | EVGA RTX 2070 Black edition
    Fractal Arc Midi |Seasonic X650 PSU | Klipsch ProMedia 5.1 Ultra | Windows 10 Pro x64

  3. #3
    Ursus Arctos Moderatis Grizzly's Avatar
    Join Date
    Sep 2000
    Location
    Providence, RI USA
    Posts
    3,077

    Post

    This won't test version, but this simple dimple piece of JavaScript will determine if it's IE, or Netscape:

    <script language="JavaScript">
    if (navigator.appName == "Microsoft Internet Explorer")
    {
    location.href = "index2.html";
    }
    else
    {
    location.href = "index3.html";
    }
    </script>

  4. #4
    Great White Shark
    Join Date
    Nov 2000
    Location
    Alpharetta, Denial, Only certain songs.
    Posts
    9,925

    Post

    In that case, would this be a browser/version script? This is taken(cut/pasted) from the site I linked to earlier.

    <SCRIPT LANGUAGE="javascript">
    <!--
    window.name='MainFrame';

    function open_content_win(win) {
    browser_name = navigator.appName;
    browser_version = parseFloat(navigator.appVersion);
    str= win;

    if (browser_name == "Microsoft Internet Explorer" && browser_version < 5.0) {
    searchWin = window.open(str,'searchWin','resizable=no,scrollbars=yes,wid th=620,height=480,status=no,location=no,toolbar=no,menubar=n o');

    window.open(str,'searchWin','resizable=no,scrollbars=yes,wid th=620,height=480,status=no,location=no,toolbar=no,menubar=n o');
    }
    else if (browser_name == "Netscape" && browser_version <= 4.01) {
    searchWin = window.open(str,'searchWin','resizable=no,scrollbars=yes,wid th=620,height=540,status=no,location=no,toolbar=no,menubar=n o');

    window.open(str,'searchWin','resizable=no,scrollbars=yes,wid th=520,height=540,status=no,location=no,toolbar=no,menubar=n o');

    if (browser_version >= 3.0) {
    searchWin.focus();
    }
    searchWin.refer = self;
    }
    else {
    searchWin = window.open(str,'searchWin','resizable=no,scrollbars=yes,wid th=640,height=520,status=no,location=no,toolbar=no,menubar=n o');

    window.open(str,'searchWin','resizable=no,scrollbars=yes,wid th=640,height=520,status=no,location=no,toolbar=no,menubar=n o');

    searchWin.focus();
    searchWin.refer = self;
    }
    }

    //-->
    </SCRIPT>

    ------------------
    "I'd kill for you, Marge. Please ask me to kill for you." -Homer Simpson

    Crusader for the 64-bit Era.
    New Rule: 2GB per core, minimum.

    Intel i7-9700K | Asrock Z390 Phantom Gaming ITX | Samsung 970 Evo 2TB SSD
    64GB DDR4-2666 Samsung | EVGA RTX 2070 Black edition
    Fractal Arc Midi |Seasonic X650 PSU | Klipsch ProMedia 5.1 Ultra | Windows 10 Pro x64

  5. #5
    Ursus Arctos Moderatis Grizzly's Avatar
    Join Date
    Sep 2000
    Location
    Providence, RI USA
    Posts
    3,077

    Post

    Aye, that's a bloated script that is doing stuff you don't need though. Just plug in those "navigator.appVersion" paremeters in your 'if' statements, and adjust accordingly.

    Example:

    <script language="JavaScript">
    if (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion >= 5.0)
    {
    location.href = "index2.html";
    }
    elseif (navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion < 5.0)
    {
    location.href = "index3.html";
    }
    else
    {
    location.href = "index4.html";
    }
    </script>

    [This message has been edited by Grizzly (edited January 11, 2001).]

  6. #6
    Great White Shark
    Join Date
    Nov 2000
    Location
    Alpharetta, Denial, Only certain songs.
    Posts
    9,925

    Post

    Sorry, Griz. I had used the Rip out and paste method straight from the source code on Netscape's site. It was definitely bloated, but not knowing Java myself, I did not know how to par it down.

    ------------------
    "I'd kill for you, Marge. Please ask me to kill for you." -Homer Simpson

    Crusader for the 64-bit Era.
    New Rule: 2GB per core, minimum.

    Intel i7-9700K | Asrock Z390 Phantom Gaming ITX | Samsung 970 Evo 2TB SSD
    64GB DDR4-2666 Samsung | EVGA RTX 2070 Black edition
    Fractal Arc Midi |Seasonic X650 PSU | Klipsch ProMedia 5.1 Ultra | Windows 10 Pro x64

  7. #7
    Hammerhead Shark slipgun's Avatar
    Join Date
    Oct 2000
    Location
    Torrance, CA
    Posts
    2,513

    Post

    Quite a few scripts here. Aren't Java and JavaScript different languages?

    ------------------
    I, Bin Laden, declare a day of mourning in the whole of the Middle East over the death of an atomic bomb buried in the seabed of the Pacific

    [This message has been edited by slipgun (edited January 12, 2001).]

  8. #8
    Ursus Arctos Moderatis Grizzly's Avatar
    Join Date
    Sep 2000
    Location
    Providence, RI USA
    Posts
    3,077

    Post

    Originally posted by James:
    Sorry, Griz. I had used the Rip out and paste method straight from the source code on Netscape's site. It was definitely bloated, but not knowing Java myself, I did not know how to par it down.


    Hey whatever floats your boat James!

    And yeah Slippy, JavaScript and Java are two different things entirely. JavaScript is a web scripting language, and Java is a full blown Object Oriented Programming Language.

  9. #9
    Reef Shark Pestilence's Avatar
    Join Date
    Dec 2000
    Location
    Hickville, USA. :(
    Posts
    353

    Wink

    Thanks for the help all, I'm sure I'll be able to rip all the code I need from there.

    ------------------
    Kill em all and let God sort'em out.

    WoU
    Orc, 4.9k acres
    God damnit, better graphics != revolutionary gaming! Get it through your skull!

  10. #10
    Tiger Shark GrayCalx's Avatar
    Join Date
    Nov 2000
    Location
    Northern VA
    Posts
    569

    Post

    Originally posted by slipgun:
    Quite a few scripts here. Aren't Java and JavaScript different languages?


    Yeah they are. Java is more of a C++ type of language, whereas javascipt is pretty much strictly used in web pages, and is client-sided (its loaded onto the clients computer as the page downloads and runs from there). For anyone who cares...
    XP 1600+
    MSI KT333
    512 PC2700
    AOpen Geforce4 4200

Posting Permissions

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