Listen to Post action

I am writing a plugin that adds a custom metabox to the post page. I would like to trigger an event when the user navigates away from the edit post page or when a user stops editing a specific post. Is there a way to listen to events on the post page?

Related posts

Leave a Reply

1 comment

  1. This is more of a JavaScript the A WordPress Question but anyway, You can use the JavaScript onbeforeunload event something like:

    <script type="text/javascript">
        old = window.onbeforeunload;
        window.onbeforeunload = MyOnExit;
        function MyOnExit(){
            //do your stuff here
            return old();
        }
    </script>