Bug 11740 - Javascript generated mailto: link (on Form submit) does not work in Safari
Summary: Javascript generated mailto: link (on Form submit) does not work in Safari
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
URL: http://www.digitalmars.com/contact.html
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-01 19:25 PST by Alexei Svitkine
Modified: 2007-10-21 22:47 PDT (History)
3 users (show)

See Also:


Attachments
test case (with javascript: URL) (218 bytes, text/html)
2007-10-21 22:37 PDT, Alexey Proskuryakov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexei Svitkine 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/ ).
Comment 1 Ain Tohvri 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.
Comment 2 Alexei Svitkine 2007-10-19 18:13:04 PDT
But it works in other browsers. Which makes Safari the incompatible one.
Comment 3 Ain Tohvri 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.
Comment 4 Ain Tohvri 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.
Comment 5 Alexey Proskuryakov 2007-10-21 22:37:24 PDT
Created attachment 16782 [details]
test case (with javascript: URL)
Comment 6 Alexey Proskuryakov 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.