Thursday, October 23, 2025
HomeLanguagesJavascriptHTML DOMException message Property

HTML DOMException message Property

The DOMException message property returns a DOMString representing a message or description associated with the given error. This is a read-only property.

Syntax:

domException.message

Return Value: This property returns a DOMString associated with an error.

Example: This example illustrates the use of DOMException message property.

HTML




<!DOCTYPE html>
<html>
 
<body>
    <h1>neveropen</h1>
 
     
     
<p>
        Click below to get
        the exception message
    </p>
 
 
 
    <button onclick="get()">Click</button>
 
    <p class="p">Error Message is : </p>
 
 
 
    <script>
        function get() {
            try {
                // INVALID_CHARACTER_ERR
                var elem = document
                    .createAttribute("123");
            }
            catch (e) {
                document.querySelector(".p")
                    .textContent += e.message;
            }
        }
    </script>
</body>
 
</html>


Output:

Before Clicking the Button:

After Clicking the Button:

Supported Browsers: 

  • Google Chrome 1
  • Edge 12
  • Firefox 1
  • Internet Explorer 9
  • Safari 1
  • Opera 12.1
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS