spacer
Yehuda Shiran January 23, 2001
A Short Browser Sniffer
Tips: January 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Until Netscape 6 and Internet Explorer 5.x are fully deployed, we need to support Netscape Navigator 4.x and Internet Explorer 4.x. The four lines below identifies which browser you are running on. Internet Explorer 4.x is detected by having the document.all object, and by not supporting the document.getElementById method. Netscape Navigator 4.x is recognized by having the document.layers object. Internet Explorer 5.x has the document.all object and supports the document.getElementById method. Netscape 6 supports the document.getElementById method and does not have the document.all object. Here is the code:

var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var N6 = (document.getElementById && !document.all) ? true : false;

Click the button below to find the browser name:


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business