javascript - How to redirect page when user close tab or window -
sorry if question exists search don't want when user close window show him message we've special offer , if says yes redirect page otherwise close window
but what's happening showing alert not on closing tab when going other same website link also.
here's code :
<script src="http://code.jquery.com/jquery-latest.min.js"></script> <script> window.onbeforeunload = function() { alert('1'); }; $(document).ready(function() { $('a').click(function() { window.onbeforeunload = null; }); $('form').submit(function() { window.onbeforeunload = null; }); }); </script>
Comments
Post a Comment