Hi everbody,
i have a problem with a javascript script.
it doesn't work well on Netscape 6x-7 (on both Win and Mac) and also on
Explorer 5x (Mac).
I modified the original version and i could get some improvements (also on
Mac-browsers);
now it works better, but it still doesn't display the Alert message
correctly.
The script looks like that:
<script LANGUAGE="Javascript">
function suddenExit(e)
{
if(!e) e = window.event;
py=e.clientY;
if (py<0){
if(e.preventDefault) e.preventDefault()
else e.returnValue=true
event.returnValue="ATTENTION! By closing the window in this way, the
system will not save the data \n If you...etc etc
";
}
//alert(py + "If you exit, tour data wil not be correctly registered!")
}
function warn_dataLoss(){
if(navigator.userAgent.toLowerCase().indexOf("msie")==-1 || window.opera){
alert("Data will be lost");
}
}
.............
<body .... onbeforeunload='suddenExit(event)'
onunload="warn_dataLoss()"
- on IE 5x/mac (the message is displayed cut up at the 2nd line) at page
Refresh
- on both IE5x/mac and NN 6x-7/win+mac
the Alert is displayed only while Refreshing, NOT while Closing the
window (as it should do!) ???
I know that the event "onbeforeunload" only works on IE/win;
but the other event handler "onunload" should fire while exit/closing the
window...right?
But, it does not .... !!!
How could I fix this problem,and get yhe script really "crossbrowser" ?
Bye, thanx in advance
PS:
If you need to see the whole Script (or the page - which is a Popup window -
that contains the script), tell me and I'll post it.
(...sorry 4 my english...
i have a problem with a javascript script.
it doesn't work well on Netscape 6x-7 (on both Win and Mac) and also on
Explorer 5x (Mac).
I modified the original version and i could get some improvements (also on
Mac-browsers);
now it works better, but it still doesn't display the Alert message
correctly.
The script looks like that:
<script LANGUAGE="Javascript">
function suddenExit(e)
{
if(!e) e = window.event;
py=e.clientY;
if (py<0){
if(e.preventDefault) e.preventDefault()
else e.returnValue=true
event.returnValue="ATTENTION! By closing the window in this way, the
system will not save the data \n If you...etc etc
";
}
//alert(py + "If you exit, tour data wil not be correctly registered!")
}
function warn_dataLoss(){
if(navigator.userAgent.toLowerCase().indexOf("msie")==-1 || window.opera){
alert("Data will be lost");
}
}
.............
<body .... onbeforeunload='suddenExit(event)'
onunload="warn_dataLoss()"
- on IE 5x/mac (the message is displayed cut up at the 2nd line) at page
Refresh
- on both IE5x/mac and NN 6x-7/win+mac
the Alert is displayed only while Refreshing, NOT while Closing the
window (as it should do!) ???
I know that the event "onbeforeunload" only works on IE/win;
but the other event handler "onunload" should fire while exit/closing the
window...right?
But, it does not .... !!!
How could I fix this problem,and get yhe script really "crossbrowser" ?
Bye, thanx in advance
PS:
If you need to see the whole Script (or the page - which is a Popup window -
that contains the script), tell me and I'll post it.
(...sorry 4 my english...