Javascript Reference - HTML DOM isDefaultNamespace Method








The isDefaultNamespace() method returns true if the specified namespace is default, otherwise false.

Browser Support

isDefaultNamespace Yes 9.0 Yes Yes Yes

Syntax

node.isDefaultNamespace(namespaceURI)

Parameters

Parameter Type Description
namespaceURI String Required. The URI of the namespace to check




Return Value

It returns a Boolean type.

true if the namespace is default, otherwise false.

Example

The following code shows how to check if the defined namespace is the default namespace.


<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">test</button>
<script>
function myFunction()<!-- w w  w  . j ava 2s  . co m-->
{
    var d=document.documentElement;
    console.log(d.isDefaultNamespace("http://www.w3.org/1999/xhtml"));
}
</script>
</body>
</html>

The code above is rendered as follows: