jquery - Create alert message on closing popup window (Javascript) -
i have created code open youtube video in popup few seconds. working in code. need give alert user if he/she going close popup window. problem popup window not related parent window, how can close it?
here code using
$(document).ready(function() { var mywindow; $("#idview").click(function() { var vidurl = 'www.youtube.com'; counter(); mywindow = window.open(vidurl, "popupwindow", "width=600, height=400, scrollbars=yes"); }); function counter() { var n = $('.c').attr('id'); var c = n; $('.c').text(c); setinterval(function() { c++; if (c <= 41) { $('.c').text(c); } if (c == 41) { $('.c').text(n); } }, 1000); } setinterval(function() { mywindow.close(); }, 45000); window.onbeforeunload = closingcode; function closingcode() { alert('hitme'); return null; } });
i want fire function before closing popup window.
if want fire function before closing popup window. call right before closing window.
setinterval(function() { your_callback_function(); mywindow.close(); }, 45000);
Comments
Post a Comment