spacer
Yehuda Shiran March 8, 2000
Detecting Stylesheets
Tips: March 2000

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

Some applications rely on the existence of stylesheets. For a graceful exit in the case of disabled stylesheets, we need to know if they are enabled or disabled. If the browser is Internet Explorer 4.0x, stylesheets cannot be disabled. However, if the user is running Navigator 4.0x, we must find out if they are disabled by checking the existence of an element. The following code must be inserted before the script:

<SPAN ID="test" STYLE="position: absolute;"></SPAN>

The following variable determines whether or not stylesheets are enabled, by checking the livelihood of the above test id:

var style = ((NS4 && document.test) || IE4) ? 1 : 0;

NS4 is true when the Netscape Navigator version is 4 and up. IE4 is true when the Internet Explorer version is 4 and up as well.

Learn more about the application that uses this technique in Column 16, Dynamic Tooltips.


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