Jump to content

putting script in close button


anton578

Recommended Posts

Yes, you can do it using onbeforeunload event listener.

 

function confirmUnload() {
var mes = "Your message here";
if (event) {
  event.returnValue = mes;
}
else {
  // do what?
}

}

window.onbeforeunload = confirmUnload;

 

The first branch is for the standard event handling. I know that

Firefox supports this as well by now but in some rather tweaky way and

I don't have the workaround snippet handy right now, so for // do

what? someone else may help here.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.