/    Sign up×
Community /Pin to ProfileBookmark

Browser Detect (Netscape – Mozilla)

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

[code=php]<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>”);
}
document.write(“this.appN(Name) = &nbsp;”, this.appN, “<br>”, “this.appV(Version) = &nbsp;”, this.appV, “<br>”, “this.ua(userAgent) =

&nbsp;”, this.ua, “<br>”, “this.plt(Platform) = &nbsp;”, this.plt);
}
var browser = new BrowserDescription();
</script>[/code]

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?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@MasterTauthorApr 16.2004 — comon people you aint got nothin to say?

help a brother out
Copy linkTweet thisAlerts:
@VladdyApr 16.2004 — Why do you need to tell the difference between Mozilla and Netscape in the first place???

They use the same gecko engine. All you should be interested in is the word "gecko" and the number after "rv:"

Furthermore, you do not even need to look for Mozilla/Netscape, just send it compliant code :rolleyes:
Copy linkTweet thisAlerts:
@MasterTauthorApr 18.2004 — i need to tell the difference cause in Mozilla it looks different than in Netscape
Copy linkTweet thisAlerts:
@Paul_JrApr 18.2004 — [i]Originally posted by MasterT [/i]

[B]i need to tell the difference cause in Mozilla it looks different than in Netscape [/B][/QUOTE]


[i]Originally posted by Vladdy [/i]

[B]Furthermore, you do not even need to look for Mozilla/Netscape, just send it compliant code [/B][/QUOTE]
Copy linkTweet thisAlerts:
@bzendApr 23.2004 — As they use the same engine, I also used to THINK they displayed pages identically. Now, having faced the same problem as MasterT, I KNOW that it is not the case.

They seem to interpret CSS differently. I had a page which was displayed by Mozilla and Firefox exactly as I wanted, but Netscape displayed nothing but the background and the wrapper blocks shrunk to 1px high lines.

MasterT, why don't you just check the User Agent string for "Netscape". That should do the trick, wouldn't it?

(BTW, I managed to solve my problem by modifying CSS, so that I did not have to implement this)
×

Success!

Help @MasterT spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...