Javascript Reference - HTML DOM namespaceURI Property








The namespaceURI property returns URI of the specified node's namespace.

Browser Support

namespaceURI Yes 9.0 Yes Yes Yes

Syntax

var v = node.namespaceURI

Return Value

A String type value representing the URI of the node's namespace.





Example

The following code shows how to get the URI of the namespace for an XHTML document.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--   w ww.  ja v a2s.  co  m-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<body>
<p id="demo">test</p>
<button onclick="myFunction()">test</button>
<script>
function myFunction()
{
    var x=document.getElementById("demo");  
    x.innerHTML=document.documentElement.namespaceURI;
}
</script>

</body>
</html>

The code above is rendered as follows: