Javascript关闭警报框 [英] Javascript close alert box

查看:202
本文介绍了Javascript关闭警报框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想能够在一定的时间或特定的事件(即onkeypress)之后自动关闭一个警报框。从我的研究来看,内置的alert()函数看起来不一样。有没有办法来覆盖它,并控制它打开的对话框?

I want to be able to close an alert box automatically using javascript after a certain amount of time or on a specific event (i.e. onkeypress). From my research, it doesn't look like that's possible with the built-in alert() function. Is there a way to override it and have control over the dialog box that it opens?

另外,我不想要一个覆盖,显示一个隐藏的div作为警报。我需要一个实际的对话框。

Also, I don't want an override that shows a hidden div as the alert. I need an actual dialog box.

推荐答案

如前所述,你真的不能这样做。您可以使用UI框架在窗口内做一个模态对话框,或者您可以使用一个弹出窗口,一个脚本在超时后自动关闭,每个都有一个负面的方面。如果窗口最小化,浏览器中的模态窗口将不会创建任何通知,并且基于程序设计(基于计时器的)弹出窗口可能被现代浏览器和弹出窗口拦截器阻止。

As mentioned previously you really can't do this. You can do a modal dialog inside the window using a UI framework, or you can have a popup window, with a script that auto-closes after a timeout... each has a negative aspect. The modal window inside the browser won't create any notification if the window is minimized, and a programmatic (timer based) popup is likely to be blocked by modern browsers, and popup blockers.

这篇关于Javascript关闭警报框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆