When you choose “Preview”, which is actually a link,
<a class="preview button" href="https://wordpress.stackexchange.com/questions/35517/?p=52&preview=true"
id="post-preview" tabindex="4">Preview</a>
the post is saved and the preview opens in a new window.
I’m sure there is a javascript event attached to this button, I’d like to override it so that it saves and then preview link opens in the same tab / window.
1 Answer
Here’s a way to do it without modifying the core:
add_action('admin_footer','preview_same_window');
function preview_same_window(){ ?>
<script type="text/javascript">
jQuery(function($){
jQuery('.preview.button').unbind().removeAttr('target');
setTimeout(function(){
jQuery('.preview.button').unbind().removeAttr('target');
},250);
});
</script>
<?php
}