/    Sign up×
Community /Pin to ProfileBookmark

browser detection

Hi,

I need to find some javascript code to detect whether the user is on IE for PC or Netscape for PC. I would like to be able to separate them and have different style sheets for the two.

I am using some detection script to do this with mac v pc browsers and have got it working but am struggling to find the above.

Hope it is not a really basic request but if it is please forgive me as I am very new to javascript.

I look forward to hearing from you javascript gurus!

Nats

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@CharlesOct 26.2004 — navigator.platform and navigator.appName but both are bad to use. Make one pagethat works for all.
Copy linkTweet thisAlerts:
@sciguyryanOct 26.2004 — Try this, it may be of some use:


http://www.webdeveloper.com/forum/attachment.php?s=&postid=265001

You'll need to modify it a bit and work out how tho change styles but, that should not be too hard ?

RyanJ
Copy linkTweet thisAlerts:
@David_HarrisonOct 26.2004 — [i]Originally posted by nats [/i]

[B]I need to find some javascript code to detect whether the user is on IE for PC or Netscape for PC.[/B][/QUOTE]
What about Opera? What about Mozilla? What about browsers with JavaScript disabled? What about sunrise, what about rain, what about all the things that you said we were to gain?

There are a lot of browsers out there, you can't possibly detect them all, therefore do what Charles said, create a style-sheet that works for standards compliant browsers and IE.
Copy linkTweet thisAlerts:
@sciguyryanOct 26.2004 — [i]Originally posted by lavalamp [/i]

[B]What about Opera? What about Mozilla? What about browsers with JavaScript disabled? What about sunrise, what about rain, what about all the things that you said we were to gain?



There are a lot of browsers out there, you can't possibly detect them all, therefore do what Charles said, create a style-sheet that works for standards compliant browsers and IE. [/B]
[/QUOTE]


I agree, I'm updating my detector all the time but, the task is endless.


RyanJ
Copy linkTweet thisAlerts:
@David_HarrisonOct 26.2004 — [i]Originally posted by sciguyryan [/i]

[B]I agree, I'm updating my detector all the time but, the task is endless.[/B][/QUOTE]
Well if Opera is spoofing as IE (and by default it does do that) then your detector will report Opera as being Microsoft Internet Explorer.
Copy linkTweet thisAlerts:
@sciguyryanOct 26.2004 — [i]Originally posted by lavalamp [/i]

[B]Well if Opera is spoofing as IE (and by default it does do that) then your detector will report Opera as being Microsoft Internet Explorer. [/B][/QUOTE]



Thats a good point... I'll have to look into it.


RyanJ
Copy linkTweet thisAlerts:
@JPnycOct 26.2004 — Easy way around that. 2 ways, actually. 1 is use window.opera and the other is to test UA string (opera's will still contain the word opera no matter what else it contains) but you HAVE to test for Opera 1st, or it will pass another test, depending on what it's cloaked as.
×

Success!

Help @nats 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 5.29,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...