Welcome to WebmasterWorld Guest from 54.221.28.179

Forum Moderators: open

Message Too Old, No Replies

Javascript: Identifying visitor's OS and Browser

Best way?

     

kenhoho

4:54 pm on Jun 12, 2003 (gmt 0)

10+ Year Member



I've seen a bunch of scripts for this on the web, but each is slightly different... has anyone found an optimized script to ID your visitor's OS and browser?

Also, what is the best way to collect this info?

Thanks.

DrDoc

8:54 pm on Jun 12, 2003 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



DevEdge [developer.netscape.com] has a very good script.

However, there is no such thing as an "optimized" script for your needs. Do you need to recognize all browsers? Well, then it's important that many common browsers can identify themselves as any browser.

Browser sniffing is seldom very reliable. If possible, try to avoid it.

Now, the best advice I can give you is to download DevEdge's user agent sniffer. Then you need to modify it to suit your needs. Learn how to use simple JavaScript constructs as:

navigator.userAgent
navigator.appName

broadKnowledge

10:05 pm on Jun 12, 2003 (gmt 0)

10+ Year Member



I pretty much agree with the post above 'DevEdge' but in addition to that info, try to do your script in a process that gets the best results. What I mean is identify the OS first with a java script, then 'if' WIN OS run a VB if not run another java script. In most cases a WIN OS is easier to sniff than Linux etc. What I have found in general is that people who surf with browsers that run on Linux OS almost always don't want their browser to be sniffed, you have to build a round-a-bout method to sniff the browser at site's entrance. Once you sniff the OS the rest is fairly straightforward. Well! if you want to get real technical and want to accommodate wireless devices and such you will need to work harder to create a sniffer.

kenhoho

5:34 am on Jun 13, 2003 (gmt 0)

10+ Year Member



Thanks for the help. By the way, speaking of JS, it's compatible with HTML 4.0 strict, right? I'm getting an error in my w3c validation at

'<script language="JavaScript" type="text/JavaScript">'

with the validator saying 'language' isn't valid

keyplyr

7:32 am on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



Use <script type="text/javascript" src="your_script.js">

kenhoho

1:48 pm on Jun 13, 2003 (gmt 0)

10+ Year Member



Stupid question perhaps, but since I'm new to JS... I assume I drop the src= part if my script is embedded in the head of my markup?

korkus2000

1:56 pm on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member korkus2000 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Yes. Source is only needed to call an external .js file.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month