最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to avoid blocking alert box in html - Stack Overflow

programmeradmin0浏览0评论

In my HTML page I am displaying alert box many times. After few execution of alert boxes, Browser will ask

"Prevent this page from creating additional dialogs"

How can I avoid this?

Thanks.

In my HTML page I am displaying alert box many times. After few execution of alert boxes, Browser will ask

"Prevent this page from creating additional dialogs"

How can I avoid this?

Thanks.

Share Improve this question asked Jul 20, 2011 at 6:52 Royal PintoRoyal Pinto 2,9118 gold badges29 silver badges39 bronze badges 1
  • Why not using console.log("message") ? – ChristopheCVB Commented Jul 20, 2011 at 6:59
Add a ment  | 

3 Answers 3

Reset to default 6

Don't use alert for regular user notifications. Instead, use jqueryUI's or your own dialog implementation, or console.log in debugging code.

Bear in mind that modal dialog boxes tend to be user-unfriendly and should only be used in exceptional circumstances (for example, failure of AJAX munication). If you're using modal dialogs in the regular flow of an application (for example if form validation fails), consider an alternative, less intrusive notification, such as adding a red border/background to the form fields in question.

You can't. That is basically a security feature added in the browser to prevent sites from having an infinite loop making alert boxes and annoying the user.

You can't prevent this: the browser is noticing that the page keeps alerting, and assumes (often, correctly) that there is an infinite loop on the page. Preventing further alerts keeps the page usable (eg you can hit the back button).

If you are using the alerts as a way of municating important information in the normal course of operation, you might want to consider filling an element on the page with the same info. For (a very non-fancy) example, instead of

alert(x + ' just happened!');

just add a <div id="alert"></div> to the page and do

document.getElementById('alert').innerHTML(x + ' just happened!');
发布评论

评论列表(0)

  1. 暂无评论