javascript - Sequencing two action on a button click -


problem: have asp.net button , on click of displaying window using window.open() @ client side using <script></script>

"i actually, need popup(alert message) displayed on parent page button located once user closes child window."

couple of things tried follows:

  1. i tried using settimeout() have time out milliseconds. not work control not waiting untill time out complete. proceeds execute next set of code.

  2. i tried using setinterval() reason not working me. below code snippet of that.

.

$(document).ready(function () {             $('#<%=btnclick.clientid%>').bind('click', function () {                 var newwindow = window.open("http://www.google.com/", "google", 'resizable=1,width=900,height=800,scrollbars=1', '_blank');                 newwindow.moveto(0, 0);                 var test = setinterval(function (e) {                     if (newwindow.closed) {                         alert("heyy");                         clearinterval(test);                         __dopostback("<%= btnclick.uniqueid %>", "");                     }                     else {                         e.preventdefault();                     }                 }, 5000);             });         }); 

.

  1. i tried making ajax call open new window , make async : false, again did not me.

bring window , timer variable out of scope of event handler. need polling i.e. periodically keep on checking if windows has been closed. using setinterval polling job.

var newwin, polltimer;  $('#btnid').bind('click', function () {     newwin = window.open("...", "...", "");     polltimer = window.setinterval(function() {         if (newwin.closed) {              window.clearinterval(polltimer);             callcodewhenpopupcloses();         }     }, 5000); });  function callcodewhenpopupcloses() {     alert("popup closed.");     ... } 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -