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

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

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!');

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745311791a4622032.html

相关推荐

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

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

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信