WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-16-2004, 04:52 PM
WebProWorld Member
 

Join Date: Jan 2004
Location: NorCal
Posts: 64
MasterT RepRank 0
Default (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
Reply With Quote
  #2 (permalink)  
Old 02-03-2008, 10:59 AM
WebProWorld Veteran
 

Join Date: Jul 2003
Location: Bristol, UK
Posts: 965
carbonize RepRank 0
Default 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.
__________________
Carbonize
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags: , , ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0