473,473 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Submit form onUnload with Firefox

3 New Member
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 4384
gits
5,390 Recognized Expert Moderator Expert
hi ...

use the unbeforeunload-event instead ...

kind regards
Jan 22 '08 #2
ccyarm
3 New Member
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 Recognized Expert Moderator Expert
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

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

Similar topics

4
by: Yashwant | last post by:
Dear Netscape/Javascript/Java gurus, I am trying to submit a form onUnLoad when the user accidentally closes the browser before clicking on a link to complete the transaction. On IE, this...
2
by: Floortje | last post by:
Hi, im an absolute noob at javascript. I copied a timer from a site wich counts to 5 minutes and then pos up an alert. Is it possibel to automatically submit the form after I click ok ? ...
5
by: terence.parker | last post by:
I have a PHP application which I wrote last year - and the JavaScript worked fine then. For some reason, now it doesn't - neither on IE nor Firefox. Has something changed? When I click on my...
5
by: antonyliu2002 | last post by:
Hi, It looks like so many people are having problems with the javascript submit in firefox. I searched around, but haven't found a solution yet. Mostly, people were saying, try this or try...
5
by: jackchang1 | last post by:
I have an application that will submit the form when the page is closed (through onunload event), and it works fine in IE6. But it doesn't work in FireFox, and no data is sent. It seems to me that...
5
by: Steve JORDI | last post by:
Just a question using images as submit buttons and PHP4.4.4. It seems that my code correctly works in FireFox but not in IExplorer. For example, I have a FORM with 2 buttons called "search" and...
6
by: yawnmoth | last post by:
I'm trying to write a so-called bookmarklet for a specific web app and am having some difficulty. One of the names of a specific forms inputs is submit. As such, doing...
3
by: CAG | last post by:
Hello, I have following scenario in my web application. I want to load different web forms in single iframe. Iframe in contained in an ASP page. ASP page has “Submit” button, which submits iframe...
5
by: hannie | last post by:
onKeyPress does not work in Firefox. If use tab to navigate each field and press "Enter" on "Next" button to submit form and process to the next form / page, IE works well even if without onKeyPress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.