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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint