NEW 11740
Javascript generated mailto: link (on Form submit) does not work in Safari
https://bugs.webkit.org/show_bug.cgi?id=11740
Summary Javascript generated mailto: link (on Form submit) does not work in Safari
Alexei Svitkine
Reported 2006-12-01 19:25:36 PST
See: http://www.digitalmars.com/contact.html The website uses the following code to generate a mailto: link equivalent (and to prevent spam): <SCRIPT LANGUAGE="javascript"> <!-- var Domain = "digitalmars.c"; var Mailme = "mai" + "lto:w" + "gmars7@" + Domain + "om"; document.write("<FORM>"); document.write("<INPUT TYPE=\"submit\" VALUE=\"Send email to Digital Mars\" "); document.write("onClick=\"parent.location=Mailme\"> "); document.write("</FORM>"); // --> </SCRIPT> This code works fine in Firefox 2.0 (and other browsers), but fails in latest Tiger Safari, as well as nightly r17960. This is a pretty important website (Digital Mars is the creator of the D programming language, a really good language that hasn't yet caught on: http://www.digitalmars.com/d/ ).
Attachments
test case (with javascript: URL) (218 bytes, text/html)
2007-10-21 22:37 PDT, Alexey Proskuryakov
no flags
Ain Tohvri
Comment 1 2007-10-19 17:21:43 PDT
What happens is that your form gets posted. You should remove the form tags at all or set the submit to return false, e.g. <SCRIPT LANGUAGE="javascript"> var Domain = "digitalmars.c"; var Mailme = "mail"+"to:w" + "gmars7@" + Domain + "om"; var html = "<form onsubmit='return false;'><input type='submit' value='send email' onclick='javascript:document.location.href=\""+Mailme+"\"'></form>"; document.write(html); </SCRIPT> Also, you'll not get a valid code out of this with just plain-empty form tags which is not the case if you leave them out.
Alexei Svitkine
Comment 2 2007-10-19 18:13:04 PDT
But it works in other browsers. Which makes Safari the incompatible one.
Ain Tohvri
Comment 3 2007-10-20 03:55:45 PDT
I don't agree incompatibility. The latest Opera 9.24 behaves the very same way. And these are the first browsers to pass Acid2. In my humble opinion this is the case of valid coding. It is programmatically proper to be precise and strict in respect to the open standards.
Ain Tohvri
Comment 4 2007-10-20 04:04:31 PDT
By the W3C HTML 4.01 Specification: - submit buttons: When activated, a submit button submits a form. A form may contain more than one submit button.
Alexey Proskuryakov
Comment 5 2007-10-21 22:37:24 PDT
Created attachment 16782 [details] test case (with javascript: URL)
Alexey Proskuryakov
Comment 6 2007-10-21 22:47:47 PDT
We certainly want to be compatible with IE and Firefox, and I actually don't think that this behavior is non-standard. Onclick fires before submitting the form, and javascript/mailto URLs can be loaded synchronously. After that, the form is submitted. See also: bug 13011.
Note You need to log in before you can comment on or make changes to this bug.