diff --git a/files/en-us/web/api/domexception/domexception/index.html b/files/en-us/web/api/domexception/domexception/index.html index 915115ee744a6cc..c9ef4f1b6c58424 100644 --- a/files/en-us/web/api/domexception/domexception/index.html +++ b/files/en-us/web/api/domexception/domexception/index.html @@ -11,7 +11,7 @@

{{ APIRef("DOM") }}

The DOMException() constructor returns a - DOMException object with a specified message and name.

+ {{domxref("DOMException")}} object with a specified message and name.

Syntax

@@ -44,6 +44,8 @@

HTML

 <button>Trigger DOM Exception</button>
+
+<p id="output"></p>
 

JavaScript

@@ -53,16 +55,16 @@

JavaScript

button.onclick = function() { try { - throw new DOMException("Custom DOM Exception"); + throw new DOMException("Custom DOM Exception Triggered."); } catch(error) { - alert(`Error: ${error.message}`); + document.querySelector("#output").textContent = `Error: ${error.message}`; } }

Result

-

{{ EmbedLiveSample('Examples', '100%', 60) }}

+

{{ EmbedLiveSample('Examples', '100%', 100) }}

Specifications