469,646 Members | 1,339 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,646 developers. It's quick & easy.

Submit form onUnload with Firefox

3
Hello,
I need to modify the following code to make it work with Firefox. It works perfectly well with IE.
It seems to me that with Firefox all the form values are lost when the onUnload fires up.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <body onUnload="unlockrecords();" > 
  3.   <script language="javascript">
  4.  function unlockrecords()
  5.  {
  6.     // action is variable during the execution of the program
  7.     document.editreport.action="unlock.php"; 
  8.     document.editreport.submit();
  9.  }
  10.  </script>
  11.  <form  name="editreport" method="post" target="savereport" onSubmit="window.open('', this.target,'scrollbars=no, status=no, toolbar=no, resizable=no, width=500, height=500, left=0,top=0');" >
  12. ....
  13.  
  14.  
---------------------------------------------------------------------------------
Firefox will not submit the form.
Thank you for your help
Jan 22 '08 #1
3 4197
gits
5,390 Expert Mod 4TB
hi ...

use the unbeforeunload-event instead ...

kind regards
Jan 22 '08 #2
ccyarm
3
Thank you, but...

I'm already using the onbeforeunload event, if the user decides to stay on the page then I will not unlock the records:

Expand|Select|Wrap|Line Numbers
  1.  
  2. <body onUnload="unlockrecord();" onbeforeunload="setmess();"> 
  3.   <script language="javascript">
  4.  function unlockrecord()
  5.  {
  6.     window.onbeforeunload = null; 
  7.     window.onunload = null;   
  8.     document.editreport.action="unblock.php";
  9.     document.editreport.submit();
  10.  }
  11.  function setmess()
  12.  {
  13.   window.onbeforeunload = validate_exit; 
  14.  }
  15.  
  16.  function validate_exit()
  17.  {
  18.   mess = "You will lose the information!";
  19.   return mess;
  20.  }
  21.  </script>
  22.  <form  name="editreport" method="post" target="savereport" onSubmit="window.open('', this.target,'scrollbars=no, status=no, toolbar=no, resizable=no, width=5, height=5, left=0,top=0');" >
  23. ...
How do I submit the form only when they click OK on the onbeforeunload?
Thanks!
Jan 22 '08 #3
gits
5,390 Expert Mod 4TB
then i think the only way would be to check whether the user has submitted the form already or not ... and force him to do so explicitly before leaving the page ...

kind regards
Jan 22 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Yashwant | last post: by
2 posts views Thread by Floortje | last post: by
5 posts views Thread by terence.parker | last post: by
6 posts views Thread by yawnmoth | last post: by
3 posts views Thread by CAG | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.