This technique relates to the following sections of the guidelines:
Provide User Option to prevent Scripting Alerts
The web author should consider making the display of the non-essential alerts optional when the page first loads. Rather than defaulting the display of alerts to on when the page is loaded, consider making the default off and providing a mechanism for the user to turn them on. This is especially important if the display of alerts is triggered by some sort of timing mechanism where the user might have difficulty navigating to the button to turn off the alerts before another alert was displayed. While not desirable, this looping technique was used here in order to provide a simple, self contained example.
For this example the alerts are started when the page is loaded:
Within the body of the page, include a way to turn off the alerts. Below is one example.
<p>This page uses alerts, if you do not want any alerts displayed, press this button <button id="disableBtn" type="button" onclick="disableAlerts();">Turn Alerts Off</button> </p>