From 0e1056cf838c2d09884a1819f221a39500de41eb Mon Sep 17 00:00:00 2001 From: Anil Seervi Date: Sun, 8 Aug 2021 10:47:43 +0530 Subject: [PATCH] Replace usage of alert() --- .../en-us/web/api/domexception/domexception/index.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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