onUnload method on plugin WordPress

I’m creating a plugin for WordPress. But
I can’t enter the method onUnload.

I tried to include it in the body tag, but doesn’t work.

Read More

Is there a way to use this method?

Related posts

Leave a Reply

2 comments

  1. Solution by OP.

    <script type=”text/javascript”>
    
    window.onbeforeunload = askUser;
    
    function askUser(){
      return “The changes you made will be lost if you navigate away from this page”;
    }
    
    </script>