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?
Submit Your Article
Forum Rules

Reply With Quote
