spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column76


Netscape 6, Part V: DOCJSLIB 1.1

Developer News
Google Going Native With Chrome
Mozilla Fixes Firefox Flaws as 3.5 Release Nears
Microsoft and Novell Still Bosom Buddies

Sniffing the Browser Type

The first change we need to make in DOCJSLIB is sniffing for new browser types. We identify Internet Explorer 4.x by its support of document.all and by its lack of support of document.getElementById:

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

To identify Netscape Navigator 4.x is quite easy: it's the only browser to support document.layers:

var NS4 = (document.layers) ? true : false;

We distinguish Internet Explorer 5.x from the rest of the gang by its support of both document.all and document.getElementById:

var IE5 = (document.all && document.getElementById) ? true : false;

We recognize Netscape 6 and other Mozilla-based browsers by their support of document.getElementById and by their lack of support of document.all. The lack of support of document.all is important because that's one of the unique differentiators between Netscape 6 and Internet Explorer 5.x. Netscape 6's support of document.getElementById is not unique as Internet Explorer 5.x supports it as well.

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

Here is DOCJSLIB 1.1's sniffer in full:

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;

Next: How to use DOCJSLIB's image model

http://www.internet.com

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 >
XML and PHP Simplified · Creating a ASP.NET Contact Form · Data Filtering with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Intel to Host Live Nehalem Q&A · 12 Tips to Troubleshoot Network File-Sharing · 10 Tips for Selling on Kijiji


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: January 29, 2001
Revised: January 29, 2001

URL: http://www.webreference.com/js/column76/3.html