Inside JavaScript

The localName , namespaceURI , and prefix Properties

You use the localName , namespaceURI , and prefix properties mostly with XML documentsor XML embedded in HTML documentsthat uses namespaces. We won't have that much use for namespaces in this book, but, briefly , you can declare and use a namespace in XML like this:

<doc xmlns:ns="http://www.ns.com"> <ns:myElement>Here is some data</ns:myElement> </doc>

Here, "ns" is the namespace's prefix, " http://www.ns.com " is the namespace's URI, and the local name of an tag such as <ns:myElement> is just the part without the namespace prefix, "myElement" . These items correspond to the localName , namespaceURI , and prefix properties, and you can find the support for these properties in Table 5.34.

Tip

For more on XML, see the W3C XML specification at www.w3.org/TR/REC-xml. See also the scopeName property in this chapter.

Table 5.34. The localName , namespaceURI , and prefix Properties

Property

NS2

NS3

NS4

NS6

IE3a

IE3b

IE4

IE5

IE5.5

IE6

localName

     

x

         

x

 

Read-only

 

Type: String

namespaceURI

     

x

         

x

 

Read-only

 

Type: String

prefix

     

x

         

x

 

Read-only

 

Type: String

Категории