Reputation: 21
I have coding which is working in IE but not in firefox and chrome...
function handleWindowClose() {
if ((window.event.clientX < 0) || (window.event.clientY < 0))
{
event.returnValue = "Are You sure to leave this page";
}
}
window.onbeforeunload = handleWindowClose;
Can anyone help me...
Upvotes: 1
Views: 22479
Reputation: 31801
window.event
is a IE-only thing.
To get it to work in other browsers you have to get the event as an argument of the handler function:
function handleWindowClose(e) {
e = window.event || e;
if ((e.clientX < 0) || (e.clientY < 0))
{
e.returnValue = "Are You sure to leave this page";
}
}
window.onbeforeunload = handleWindowClose;
Upvotes: 8
Reputation: 539
maybe just add mousemove handler that will store mouse position in variable
var mouse;
function storeMouse(e)
{
if(!e) e = window.event;
mouse = {clientX: e.clientX, clientX:e.clientY};
}
function test(e){
alert(mouse.clientX);
}
and use jquery?
$(window).bind('beforeunload', function() {
if (iWantTo) {
return 'Are You sure to leave this page';
}
});
Upvotes: 1