Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New to the CF scene
    Join Date
    Mar 2003
    Location
    Verona - Italy
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Javascript and Netscape (?)

    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:

    Code:
     <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...)

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried this in a few different mozilla builds (ns6,ns7, phoenix) and it kinda comes and goes - sometimes it works, sometimes not.

    I'm not too sure of the reason why it sometimes wouldn't work; I was always 'brought-up' thinking onunload is an unreliable event, and not to use it.

    So unless someone knows better than this, my advice is not to rely on those events for what you're doing.

    What are you doing? You need to make sure that data has been saved before page exit? Can you save the data automatically, something like that?
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #3
    New to the CF scene
    Join Date
    Mar 2003
    Location
    Verona - Italy
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanx for your reply!

    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 th eresukts and th evaluation.
    Th e 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) !!??

    You seem to suggest to drop those events like "onunload"...but which
    other kinda Events shuold i take into consiferantio to get what
    "onbeforeunload" and "onunload" would do ?
    i'm clueless...
    Attached Files Attached Files

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah I can see where you're coming from - the problem is that even if onunload were reliable, the alert doesn't happen until after the window is closed.

    I can't give you a concrete technical answer; I've never tried to take such control over a window. What I would do is either make it clear at the start of the test that only completed tests will be saved, or auto-save yourself after each question.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #5
    New to the CF scene
    Join Date
    Mar 2003
    Location
    Verona - Italy
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what do you mean with :

    Originally posted by brothercake
    auto-save yourself after each question.
    ?


    Is there really no way to get on Netscape the same (or, at least, quite the same) as it happens on Explorer with the onBeforeunload event?

    thanx
    Last edited by kid A; 04-02-2003 at 10:34 PM.

  • #6
    New to the CF scene
    Join Date
    Mar 2003
    Location
    Verona - Italy
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i do hope you ain't forgotten me.....

    give me a sign

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well you mentioned "save the data" - that means you must have a process by which you save the data; if it's in javascript you could do that automatically instead of waiting for the user to hit submit.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #8
    New to the CF scene
    Join Date
    Mar 2003
    Location
    Verona - Italy
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i guess the Autosave should be obtained modifying the server-side (ASP) scripts...which i actually can't access
    (and i'm not keen on SP)

    do you have some other ideas?

    thanx !

  • #9
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •