spacer

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

home / experts / javascript / column76


Netscape 6, Part V: DOCJSLIB 1.1

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

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, 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


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