Programmatically close alert () in Javascript

I am trying to close the warning as soon as an event occurs. I am currently getting a popup when the internet is disconnected (I want this). But as soon as the connection is restored, I want the pop-up window to disappear automatically - no need to delete the output 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);

thank

+4
source share
2 answers

, javascript alert(); . , , - (, , jQuery / ).

+5

Java Script . , JQuery UI - .

+1

Source: https://habr.com/ru/post/1539370/