Element namespaceURI Property - Javascript DOM

Javascript examples for DOM:Element namespaceURI

Description

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

This property is read-only.

Return Value

A String, representing the URI of the node's namespace, or null if the node is not in a namespace

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from   w  ww .  ja v a2s . c  o  m*/
    var x = document.documentElement.namespaceURI;
    document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

Related Tutorials