4 Handy Ways to Prevent Google Chrome From Closing Accidently

Related articles

6 Responses

  1. LidVan says:

    Doesn’t work. Nothing happens and tab is closing as usual.

  2. Johannes says:

    I’ve gotten Page Modifier installed and I pasted in your script and put “*” in the “Applied to:” field, but I don’t get a pop-up. It still allows me to close tabs without confirmation. I’ve turned off all other extensions and rebooted Chrome once just to be sure, but it’s still not working.

    Any thoughts?

    • Sorry to hear Johannes that it did not work. I think the culprit are the quotes in the script. Can you please paste the script first in a notepad and then in the extension and see if that works?

  3. Johannes says:

    Changing the double quotes to single quotes seems to have fixed it. The working script looks like this:

    function PopIt() { return ‘Are you sure you want to leave?’; }
    function UnPopIt() { /* nothing to return */ }

    $(document).ready(function() {
    window.onbeforeunload = PopIt;
    $(‘a’).click(function(){ window.onbeforeunload = UnPopIt; });
    });

Leave a Reply

Your email address will not be published. Required fields are marked *