473,241 Members | 1,599 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,241 software developers and data experts.

onsubmit in form in Safari (windows)


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.
Expand|Select|Wrap|Line Numbers
  1. <html>
  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>
  13. <body>
  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>
  20. </body>
  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. }
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, 306 views)
File Type: txt mootools_1_11.js.txt (93.0 KB, 556 views)
Jan 2 '10 #1
2 4732
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

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...
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...
by: Richard | last post by:
Hello MyMainWebPage.aspx contains MyUserControl.ascx MyUserControl.ascx has a DataTable Property MyDataTable
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...
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...
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...
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...
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...
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??
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.