November 23, 2000 - Counting Attributes | WebReference

November 23, 2000 - Counting Attributes

Yehuda Shiran November 23, 2000
Counting Attributes
Tips: November 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

Netscape boasts Netscape 6 as a much more robust browser than Internet Explorer, as far as adherence to the DOM standard is concerned. For example, the attribute count feedback in Internet Explorer is not functioning. The following link runs a little script that computes the number of attributes attached to the BODY element of this tip. Here is the script:

function computeAttributes() {
var objBody = document.getElementsByTagName('BODY').item(0);
var countAttr = objBody.attributes.length;

Click the link above. If you are running Internet Explorer V5, you will get the amazing 94. If you are running Netscape 6, you should get 4, as the BODY element looks like this in this tip:

<BODY TEXT="#000000" LINK="#000099" VLINK="#000066" ALINK="#990000"> 

In fact, Internet Explorer computes a different number for every element type. 94 for BODY, 75 for HTML, 77 for P, and so on.