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 2 of 2
  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 - Trouble on Netscape + Mac-Browsers

    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
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark


  •  

    Posting Permissions

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