Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace usage of alert() in DOMException() #7698

Merged
merged 1 commit into from
Aug 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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