WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Anyone know of a nice way to disable that pop-up dialogue when exiting the post-editor? It says "This page is asking you to confirm that you want to leave - data you have entered may not be saved."

Nice feature, but annoying in certain blogs where I have to edit a ton of posts

share|improve this question

You can use the method described here. Add the following to your functions.php

function wpse35898_admin_head() {  
    <script type="text/javascript"> 
        window.onbeforeunload = function() {};
add_action( 'admin_head' , 'wpse35898_admin_head' ); 
share|improve this answer
I tried your code. I can see where it is inserting the script into the head but still no joy. Any thoughts? have you seen this in action? – endle.winters Dec 8 '11 at 21:55
I haven't tried, but it should overwrite the window.onbeforeunload event so nothing happens. Can you track that the function is called with firebug? – Naoise Golden Dec 9 '11 at 13:39
This would work, except that the window.onbeforeunload method is redefined every time the tinymce box gets out of sync with the autosaved post. If you want to prevent it from occuring again, I think you should be able to just change the text of the confirmation message to true. ie. autosaveL10n.saveAlert = true. – goldenapples Mar 16 '12 at 0:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.