以编程方式关闭Javascript中的alert() [英] Programmatically close alert() in Javascript
本文介绍了以编程方式关闭Javascript中的alert()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正试图在事件发生时触发警报关闭。目前,当互联网被淘汰时,我会得到一个弹出窗口(我希望如此)。但是一旦连接重新建立,我希望弹出窗口自动消失 - 不必点击退出或OK。
I'm trying to trigger an alert close once an event happens. Currently I get a popup when the internet cuts out (I want that). But once the connection is reestablished, I want the popup to automatically go away - not having to hit exit or OK.
我有这个代码:
setInterval(function(){
if(navigator.onLine){
( ".selector" ).popup( "close" );
}else{
window.alert("It seems you have lost connection to the internet.
Please reconnect before continuing.");
}},2000);
谢谢
推荐答案
据我所知,你无法按代码关闭javascript的 alert();
。您可以尝试使用替代通知方法,如模态窗口或其他东西(所以如果用户重新上线,您只需使用jQuery函数隐藏/删除模态框)。
As far as I know you cannot close the javascript's alert();
by code. You can try to use alternative notification method like modal window or something (so then if user is back online you can simply use jQuery function to hide/remove the modal box).
这篇关于以编程方式关闭Javascript中的alert()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文