javascript - On close tab ask for unsaved changes and then reload the page - How? -


i've come across nasty website managed refresh page every time tried close tab. couldn't close page. got around disabling javascript on page.

how it?

i've tried location.replace inside onbeforeunload , doesn't work:

window.onbeforeunload = function(e) {   window.location.replace(window.location.href); }; 

here source of page in question, don't how it:

<script type="text/javascript">         function c(b)         {             document.write(b);         }          function wrapped3(d)         {             return d.replace(/(.)(.)/g, '%$1$2');         }          function wrapped(b)         {             var tmp = window['decodeuri' + 'component'];             return tmp(wrapped3(b))         }          function show_page(a)         {             c(wrapped(a)                 .split('{{addr}}').join('//ip')                 .split('{{country}}').join('great britain')                 .split('{{region}}').join('london, city of')                 .split('{{city}}').join('london')                 .split('{{ltude}}').join('//latitude')                 .split('{{referrer}}').join('//url here')             );         }         show_page('//long string here');     </script> 

window.onbeforeunload correct solution, here example:

     var popit = true;      window.onbeforeunload = function() {            if(popit == true) {                popit = false;                return "are sure want leave?";            }      } 

http://jsfiddle.net/sqamg/3/


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -