Click to See Complete Forum and Search --> : Javascript and Netscape (?)


kid A
03-30-2003, 04:41 PM
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... :rolleyes:

khalidali63
03-31-2003, 07:48 AM
Yes post the link,that will be more help full

Cheers

Khalid

kid A
03-31-2003, 03:57 PM
iìm afraid i can't post the link...or better even if i post it, it won't help 'cuz you access ithe site thru login/pwd (which i do not have)

i only got logged in and tried to fix the problem with NN (and Mac/browsers)

Anyway, i can post the whole source codes of the page (which is a POPUP window, that manages an online test):
The code is paryly in italian (if that's a problem, i'll translate it)

CODE---> see the attached file "code.txt"


Let me know !!!!!:confused:
bye

kid A
04-01-2003, 05:08 PM
for more details about the script:

- the script is included in a Popup-window (launched by the Home of the
site, accessed by Login/pwd)
and this Popup hanles an online Test, with muliple questions, that you go
thru 'til you reach the results and the evaluation.
The whole Popup (sample), if that might help, is in the Attachment
"code.txt"
[The code is partly in italian..if that's a problem, i'll translate it ]


- what i need is to make the user sure that, if he closes the Popup-window
before finishing th eTest, the data of his Test will not be saved by the
system and he must restart the test back from the beginning;
the advice shuold also suggest that the correct way to quit the Test without
losing data is to click the Cancel-button of the DialogBox(shown when he
tries to close the Popup) and the the Exit-button in the Popup .
So, like this:
" Attention: by closing the window this way, the system will NOT
saveyour data and it will not be possible to go on ith the Test lately.
To save your data, you MUST click on CANCEL (Annulla) in this window[= i.e.the DialogBox !] and then EXIT (Esci) in the main window[= i.e. the Popuup window which handles the Test]
Only in this way, the system will show your evaluation score"

(this message is correctly shwon only on Explorer/win, as far as i know,
'cuase it's handled by Event "onBeforeunload")



So that's why i'm trying to get an Alert message before page exit also on
Ns/win (and Ns/mac as well as Explorer/mac) !!??

i'm clueless:confused: :rolleyes:

kid A
04-02-2003, 04:39 PM
HEEELP !!!!!!!