一旦事件发生,我正试图触发警报关闭.目前,当互联网被淘汰时,我会得到一个弹出窗口(我希望如此).但是一旦连接重新建立,我希望弹出窗口自动消失 - 不必点击退出或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);
Run Code Online (Sandbox Code Playgroud)
谢谢