exit events with javascript [duplicate]
Possible Duplicate:
Alert when browser window closed accidentally
When a user clicks the browser's exit button(in a sense X) I want to open a new window.
For example, The Wordpress Admin Panel: If you are in a Wordpress panel and you want to exit, wordpress opens a new window and asks a question.
I would like to do the same.
How can i achieve this?
EDIT:
But don't exit after click. for example: www.s开发者_运维百科erkanismygirl.com
You should try using [unload()][1] from jquery:
$(window).unload(function(){
//Do your call
alert('before unload');
});
EDIT - to show yes/no you should use confirm()
If you are using jquery the code will be something like following
$(window).unload( function () {
window.open('http://YOUR_WORDPRESS_URL.com','mywindow','width=400,height=200,toolbar=yes,
location=yes');
} );
精彩评论