1

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.serkanismygirl.com

Community
  • 1
  • 1
Programmer
  • 157
  • 2
  • 3
  • 11

2 Answers2

1

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()

Nicola Peluchetti
  • 76,206
  • 31
  • 145
  • 192
0

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

} );
Shamaila Tahir
  • 988
  • 2
  • 8
  • 17