473,387 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

onsubmit in form in Safari (windows)

Gents,

I have a problem (only in Safari) with the onsubmit in webforms. This topic covers the same subject: http://bytes.com/topic/javascript/an...nsubmit-safari but not as detailed as I will.

Let me illustrate the problem with examples.
The HTML:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <script type="text/javascript" src="/js/mootools_1_11.js"></script>
  5. <script type="text/javascript">
  6. function postForm(f, c) {
  7. //    $(f).send({onComplete: c});
  8.     return false;
  9. }
  10. </script>
  11. </head>
  12.  
  13. <body>
  14.  
  15. <form method="post" action="other_page.html" onsubmit="return postForm(this,function(t){alert(t.length);});">
  16.     <input type="text" name="oele" value="boele" />
  17.     <input type="submit" value="Submit" />
  18. </form>
  19.  
  20. </body>
  21.  
  22. </html>
As you can see, Mootools is my JS library (love it!). The onsubmit calls postForm with the form and a handler functions as arguments. postForm should than post the form with Ajax and call the handler ($(form).send() does that). The postForm functions returns false, and the onsubmit returns postForm, so that FALSE is in fact returned to the webform. With the $(f).send() commented (like now), it "works": the form isn't posted and the page doesn't change. But Ajax does nothing! With the (very important) line uncommented, the form posts! The page changes! << ONLY in Safari! The rest (firefox, chrome, internet explorer and opera) work fine.

So I thought, maybe returning false just isn't enough SOMETIMES (because obviously sometimes it IS enough). So Mootools has a stop function for events (where the submit is the event). So I added this to the postForm function:
Expand|Select|Wrap|Line Numbers
  1. new Event(window.event).stop();
making the function look like this:
Expand|Select|Wrap|Line Numbers
  1. function postForm(f, c) {
  2.     new Event(window.event).stop();
  3.     $(f).send({onComplete: c});
  4.     return false;
  5. }
  6.  
In a way that was a solution: the form didn't post anymore and the page didn't change. But the Ajax request didn't fire either!! So the event.stop() halted the entire event and it's child process(es)! Again: in Firefox, Chrome, IE and Opera, this method works fine.

Does anyone know the problem and a solution? It doesn't have to be pretty, but it has to be possible with Mootools. Thanks a bunch
Attached Files
File Type: txt form.html.txt (492 Bytes, 309 views)
File Type: txt mootools_1_11.js.txt (93.0 KB, 556 views)
Jan 2 '10 #1
2 4747
acoder
16,027 Expert Mod 8TB
I don't know if this might be the solution, but often when something like this happens, there's a JavaScript error which causes it, i.e. when there's an error in the script, the rest of the code will be ignored and the form will be posted. That means there may be a problem in the Mootools send method in Safari. Not definite by any means, but something you could look into.
Jan 8 '10 #2
A litte late but very thankful.
acoder, you were absolutely right. And the error was my own fault :( I edited the mootools lib so that Safari didn't understand it anymore, which led to a very indirect javascript Type error.
And now it works! Perfect!
Jun 13 '10 #3

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

Similar topics

6
by: Hamed | last post by:
Hello I have employed as a developer in a software company that its team uses FoxPro / VB 6.0 / VC++ 6.0 as the developing tools and newly is going to migrate to VS.NET. There is a project...
2
by: JM Rosengard | last post by:
Hi, It seems that unlike other browsers, Safari will submit a form even when the onsubmit event handler returns false. e.g. <form onsubmit="return false" ...> Is there a workaround to prevent...
1
by: Richard | last post by:
Hello MyMainWebPage.aspx contains MyUserControl.ascx MyUserControl.ascx has a DataTable Property MyDataTable
8
by: hoofbeats95 | last post by:
I don't think this should be this complicated, but I can't figure it out. I've worked with C# for several years now, but in a web environment, not with windows form. I have a form with a query...
3
by: Amir Michail | last post by:
Hi, I have bookmarklets with a # in their urls but safari changes the # to %23. And unfortunately, the bookmarklet does not work with %23. You need to change it back manually to #. Any...
5
by: plumba | last post by:
Hi all I have a form (see below), which for some reason has decided to stop functioning all together. It just does not call up the function. It is called up in the opening <form> tag but...
1
by: aruncjose31 | last post by:
Hi, I have a requirement to create windows service. The requirement is to call a windows form while installing the service and to set some configuration parameters. Iam not able to call...
0
by: arora.dipti | last post by:
Hi, I am having a windows application in which i have one windows form which derives from one base form.the base form has some controls whose tabindex is set there in the form. In my derived form...
4
by: Sport Girl | last post by:
Hi everybody, please can anybody give me a hand in this issue: I cannot find the way how to redirect to an another form in Windows Application. What should I write in the code??
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.