November 28, 2000 - Tag Extraction
November 28, 2000 Tag Extraction Tips: November 2000
Yehuda Shiran, Ph.D.
|
document.all.tags()
method and the document.getElementsByTagName()
method. On the other hand, Netscape 6 supports only the official W3C's standard document.getElementsByTagName()
method. The following handleAllTags()
function extracts all FONT
tags and print their total count. We use the document.all.tags()
method in Internet Explorer, and the getElementsByTagName()
in Netscape 6:
<SCRIPT LANGUAGE="JavaScript">
<!--
function handleAllTags() {
var arrayOfFonts;
if (document.all) {
arrayOfFonts = document.all.tags("font");
}
else if (document.getElementById) {
arrayOfFonts = document.getElementsByTagName("font");
}
else {
document.write("Unrecognized Browser Detected");
}
document.write("Number of font tags is " + arrayOfFonts.length);
}
// -->
</SCRIPT>