By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,921 Members | 1,466 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,921 IT Pros & Developers. It's quick & easy.

Submit form onUnload with Firefox

P: 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
Share this Question
Share on Google+
3 Replies


gits
Expert Mod 5K+
P: 5,329
hi ...

use the unbeforeunload-event instead ...

kind regards
Jan 22 '08 #2

P: 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
Expert Mod 5K+
P: 5,329
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.