- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM isDefaultNamespace( ) Method
The HTML DOM isDefaultNamespace() method returns a boolean value (true/false) if specified namespace is default or not.
Note − An element node inherits the namespace of its parent node, therefore, all elements in an XHTML document has the namespaceURI "http://www.w3.org/1999/xhtml".
Syntax
Following is the syntax −
Calling isDefaultNamespace()
document.documentElement.isDefaultNamespace("nameSpaceURI")
Example
Let us see an example for isDefaultNamespace() method −
<!DOCTYPE html> <html> <head> <title>isDefaultNamespace()</title> <style> form { width:70%; margin: 0 auto; text-align: center; } * { padding: 2px; margin:5px; } input[type="button"] { border-radius: 10px; } </style> </head> <body> <form> <fieldset> <legend>isDefaultNamespace( )</legend> <label for="textSelect">URI: <input type="url" size="25" id="textSelect" placeholder="http://www.abc.com"> </label><br> <input type="button" onclick="confirmNameSpace()" value="Check"> <div id="divDisplay"></div> </fieldset> </form> <script> var divDisplay = document.getElementById("divDisplay"); var inputText = document.getElementById("textSelect"); divDisplay.textContent = 'NOTE: Check if specified URI is DefaultNamespace'; function confirmNameSpace() { if(document.documentElement.isDefaultNamespace(textSelect.value)) divDisplay.textContent = 'Above given namespace is default'; else divDisplay.textContent = 'Above given namespace is not default'; } </script> </body> </html>
Output
This will produce the following output −
Before clicking ‘Check’ button −
After clicking ‘Check’ button with invalid input −
After clicking ‘Check’ button with valid input −
Advertisements