문제

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.

I have this code:

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

Thanks

도움이 되었습니까?

해결책

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).

다른 팁

According to my knowledge Java Script Alert box cant be change or close programmatically. So you can use Jquery UI Dialog box or bootstrap model or something else.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top