Submit Your Article Forum Rules

Results 1 to 2 of 2

Thread: (JS) Browser Detect (Netscape - Mozilla)

  1. #1

    (JS) Browser Detect (Netscape - Mozilla)

    Hey im working on a browser detect script for my .css imports here is the script

    Code:
    <script type="text/javascript" language="javascript"> 
    BrowserDescription = function () { 
        this.appN = navigator.appName.toLowerCase(); 
        this.appV = parseInt(navigator.appVersion); 
        this.ua = navigator.userAgent.toLowerCase(); 
        this.plt = navigator.platform.toLowerCase(); 
        if (this.ua.indexOf('opera/7') != -1 || this.ua.indexOf('opera 7') != -1) { 
            this.appV = 7; 
        } 
        if (this.appN.indexOf('netscape') != -1) { 
            document.write("<link href=SignsNS.css rel=stylesheet type=text/css media=screen>"); 
        } 
        if (this.appN.indexOf('microsoft internet explorer') != -1) { 
            document.write("<link href=Signs.css rel=stylesheet type=text/css media=screen>"); 
        }     
    
    } 
    var browser = new BrowserDescription(); 
    </script>

    here is the results for Mozilla
    this.appN(Name) = netscape
    this.appV(Version) = 5
    this.ua(userAgent) = mozilla/5.0 (windows; u; winnt4.0; en-us; rv:1.6) gecko/20040113
    this.plt(Platform) = win32


    and Netscape
    this.appN(Name) = netscape
    this.appV(Version) = 5
    this.ua(userAgent) = mozilla/5.0 (windows; u; winnt4.0; en-us; rv:1.4) gecko/20030624 netscape/7.1 (ax)
    this.plt(Platform) = win32


    so im guessing that i'd have to use this.ua to tell the difference between the both but then there is a problem with the versions cause i could put
    if {this.ua = mozilla/5.0 (windows; u; winnt4.0; en-us; rv:1.6) gecko/20040113
    then use mozilla css
    if {this.ua = mozilla/5.0 (windows; u; winnt4.0; en-us; rv:1.4) gecko/20030624 netscape/7.1 (ax)}
    then use netscape css

    is there a better way?
    http://mxtracks.us/images/MXTracksLogo.gif
    California MX Tracks, Games, Photos, whatever you want its here

  2. #2
    Senior Member
    Join Date
    Jul 2003
    Posts
    518

    Re: (JS) Browser Detect (Netscape - Mozilla)

    Surely if they use the Gecko engine then they will render pages the same and so you can use the same CSS for both?

    If ua contains Opera it's Opera, If it contains Gecko it uses Gecko else it uses the IE engine (mosaic?). Oh and of course there's the Safari rendering engine.

Similar Threads

  1. Is Mozilla the best browser???
    By justin.taylor in forum Other Engines/Directories
    Replies: 88
    Last Post: 02-18-2008, 02:48 PM
  2. Netscape launches browser beta
    By WPW_Feedbot in forum IT Discussion Forum
    Replies: 0
    Last Post: 03-03-2005, 01:30 PM
  3. Netscape readies antiphishing browser
    By WPW_Feedbot in forum IT Discussion Forum
    Replies: 0
    Last Post: 01-31-2005, 10:00 PM
  4. CSS and Netscape/Mozilla/Firefox
    By ackerley1 in forum Submit Your Site/Logo For Review
    Replies: 1
    Last Post: 01-12-2005, 08:09 PM
  5. CSS <div> height problem with mozilla/netscape, help!
    By geod in forum Web Programming Discussion Forum
    Replies: 2
    Last Post: 05-29-2004, 01:59 AM

Posting Permissions

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