Skip to content

Commit

Permalink
Replace usage of alert() in DOMException() (#7698)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnilSeervi authored Aug 8, 2021
1 parent 36481e8 commit 437b776
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions files/en-us/web/api/domexception/domexception/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<p>{{ APIRef("DOM") }}</p>

<p>The <strong><code>DOMException()</code></strong> constructor returns a
<code>DOMException</code> object with a specified message and name.</p>
<code>{{domxref("DOMException")}}</code> object with a specified message and name.</p>

<h2 id="Syntax">Syntax</h2>

Expand Down Expand Up @@ -44,6 +44,8 @@ <h3>HTML</h3>

<pre class="brush: html">
&lt;button&gt;Trigger DOM Exception&lt;/button&gt;

&lt;p id="output"&gt;&lt;/p&gt;
</pre>

<h3>JavaScript</h3>
Expand All @@ -53,16 +55,16 @@ <h3>JavaScript</h3>

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}`;
}
}
</pre>

<h3>Result</h3>

<p>{{ EmbedLiveSample('Examples', '100%', 60) }}</p>
<p>{{ EmbedLiveSample('Examples', '100%', 100) }}</p>

<h2 id="Specifications">Specifications</h2>

Expand Down

0 comments on commit 437b776

Please sign in to comment.