The id Property


The id Property

As you can guess, the id property corresponds to the ID HTML attribute, and holds an object's ID value. Working with ID values is relatively new for browsers, coming in largely because the W3C DOM emphasizes the ID attribute over the NAME attribute. You can see the support for these properties in Table 5.26.

Table 5.26. The id Property

Property

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

id

     

x

   

x

x

x

x

 

Read-only

 

Type: String

Here's an example extending the code in the document object topic earlier in this chapter; in this case, I'll report an object's ID when displaying a warning in the object's document:

 function warner(object1)  {      if(object1.isBad()){  object1.document.write("WARNING: Bad Object Found! ID:" object1.id)  }  } 


Inside Javascript
Inside JavaScript
ISBN: 0735712859
EAN: 2147483647
Year: 2005
Pages: 492
Authors: Steve Holzner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net