Javascript关闭警报框

编程入门 行业动态 更新时间:2024-10-28 14:26:49
本文介绍了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关闭警报框

本文发布于:2023-11-27 16:46:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638800.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   Javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!