homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Javascript: Identifying visitor's OS and Browser
Best way?

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

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?




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

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:



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

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.


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

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


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

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


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

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?


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

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved