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>
Related Posts:
- Using radio button meta data from a custom meta box
- Stop WordPress Wrapping Images In A “P” Tag
- How to add an admin notice upon post save/update
- Keyboard shortcut for updating a page or post?
- Passing current cookies in wp_remote_get to get Draft Post Preview
- Customizing HTML Editor Quicktags button to open a dialog for choosing insert options
- Allow user to “edit_others_posts” to save only, not publish
- How can I retrieve multiple get_post_meta values efficiently?
- Let private posts stay in status “private” after edit through “editors”
- how to limit edit_form_after_title hook to page and post edit only?
- Can I force a metabox to be in one column?
- How to add a new tab to page editor
- How to create WP Editor using javascript
- How to add editor’s name to entry meta byline?
- How to add metabox for post of specific category
- Manipulate post category after time
- How to batch update post content with custom post meta value
- upload image in a meta box
- WooCommerce – Create Products Programatically [closed]
- Restrict access to post if it is currently being edited
- Change padding to text indent in “Increase indent” TinyMCE
- How can I allow editors to leave comments on posts that have not yet been published?
- Automatically added brs and paragraphs?
- which action to hook to in order to perform post-publish action
- meta_box or custom_field as a second tinymce post-instance?
- Cannot access current post’s ID in custom plugin
- How can I pass $post object to ‘save_post’ add_action?
- Set number of article per number of page
- 1 column admin screen options – move submitdiv to bottom
- How to change post status from publish to draft using hook in wordpress?
- multicheck box for post metabox
- Create A Metabox For A Custom Field
- prevent showing posts of an specific category in admin posts section
- Have save_post write to database image meta [closed]
- Custom function for “Submit for Review” hook
- add image map script to post
- Content editor creating blank paragraphs in spaces and creating   in the_excerpt
- What Can I Use To Add A Custom Button Between Publish button and Move To Trash?
- 2nd button row from WP Super Edit or TinyMCE Advanced doesn’t show to 2nd admin
- Save list from a custom meta box?
- Using Custom Posts with Metaboxes and Drop-downs
- Strange problems when I try to insert HTML\XML code snippet in my posts
- How can I add a meta-box to the posts editor containing all items of a custom taxonomy as checkbox?
- How to store an extra (surrogate) ID when creating a post with wp_insert_post?
- Visual / HTML tabs vanished on editor
- Global $post not working in OOP function WordPress
- Getting a 404 error when clicking edit page
- Automatic value for custom fields for posts
- How to rename “Publish” metabox title in post screen
- Understanding and using metaboxes in posts
- WordPress version 3.8 – Preview button not working for editor
- How to retrieve the postID in a “image_send_to_editor” hook function?
- Define a wordpress constant through plugin functions?
- Dashboard :10 Last draft page and 10 last pending review page (metabox)
- Make Post Editor Select Number of Columns To 1 By Default
- How to get post bulk edit action trigger and get edited post ids?
- Adding custom fields to bbpress reply form
- updating a post doesn’t trigger a function
- Hide a specific category in admin All Posts page (WordPress)
- Prevent Delete Attachment by URL or When Submit
- Meta value does not save for scheduled posts
- What hook do you use to update a post?
- Updating post data on save (save_post vs wp_insert_post_data)
- Lost draft under all posts and drafts
- Simultaneous admin updates causes custom fields to not update
- How to add a widget to the post editing view?
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- How to I retrieve the ID from the Posts page?
- How to save meta checkbox WordPress
- Hide custom metabox value from custom fields
- Is there a way to create a meta box that can be added multiple times to a post dynamically?
- Get post meta retrieving wrong value
- WP text styles not coming through to actual post
- Upload attachment from external site
- WordPress.com post editor replacement
- Show metabox value last post excerpt, title and link
- Filter Hook for post table (not columns)
- why str_replace targeting pages instead just targeting post?
- Why can’t publish posts with too much text?
- Updating post meta for checkbox
- How can I tell if a post has been published at least once?
- Adding JS functionality to the Publish button in wp-admin/post.php
- Get post related to particular meta box? [closed]
- Get author posts count after excluding a category
- Adding a meta box to determine the sidebar [closed]
- Stop post submission without losing data?
- Cant’ Grab WordPress Built-in Posts Through Loop
- How can my plugin display a populated new post window
- Simple Custom Metabox Not Saving
- search content of pages and list in wp-admin
- Finding a post’s slug
- Insert specific information to a posts of a predefined category
- Why my meta boxes won’t show in front post page?
- Open a wordpress single post in a lightbox without the header and footer
- Display content between two dates?
- Keyboard shortcut for headings on safari
- How to get value in radio input in post meta box?
- any way to access variables from within post editor?
- Display default matabox of posts(add category) wordpress
- Embedding Post Editor Into External Site