The tab opens this way:'/pay_wm?points='+$('#cpoints').val()+'', '', 'menubar=yes, location=yes, resizable=yes, scrollbars=yes, status=yes'); 

I need to somehow check if it is closed, then deduce alert(1) , for example. How to do it?

  • I can give a hint, and I can give a solution. What do you choose?) - lampa
  • one
    @lampa, it’s better to just prompt :) It’s necessary to do the most ^^ It seems you need to create a new window in a variable, and then if (new_window.closed) ... Not? - ModaL
  • one
    @lampa, yeah! I did! - ModaL
  • @ModaL well, you can do it when you want :-) - lampa

2 answers 2

I myself answer my question. Who cares:

 var new_window =; var new_interval = setInterval(function() { if(new_window.closed) { alert(1); clearInterval(new_interval); } }, 100); 

    If I understand you correctly, then you need to hang the handler on the unload event

    • @KryDos, I don’t know what to hang there. Well, see this example: the user clicked on the link and opened a new tab with my code. In case he closes the tab, then on the place where the link is, let alert (1) be displayed - ModaL
    • @ModaL, "in the place where the link is" - this is the place where the user clicked on the link? Or is this the tab that the user closes? That is, when you close a tab, the alert (1) will be issued to it in the same tab. - KryDos
    • @KryDos, this is where the user clicked on the link. Clicked the user on the link - the tab opened. The user created the tab closed, on the place where the user clicked on the link, an alert should pop up - ModaL