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:
i tried using
settimeout()
have time out milliseconds. not work control not waiting untill time out complete. proceeds execute next set of code.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); }); });
.
- 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
Post a Comment