开发者

exit events with javascript [duplicate]

This question already has answers here: Closed 11 years ago.

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');

} );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜