spacer
Yehuda Shiran November 28, 2000
Tag Extraction
Tips: November 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

There are several ways to extract an array of elements of the same tag type. Internet Explorer supports both the 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>


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