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

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -