View Single Post
Old 02-26-2013, 01:24 AM   PM User | #8
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,465
Thanks: 0
Thanked 499 Times in 491 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
Quote:
Originally Posted by Old Pedant View Post
I think you should *HAVE* to write
Code:
if ( document.getElementsByClassName === null ) { ... }
There is an error in your logic there. The mention of document.getElementsByClassName would presumably create it if it doesn't exist. As it now exists without having had a value allocated it now has a value of undefined and not null. When using === undefined !== null.

The correct way to write it is:

Code:
if (typeof document.getElementsByClassName === undefined ) { ... }
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is offline   Reply With Quote