whuzzup: How to I add text to a email after the site visitor clicks the “email me” button on my website?
I building a webpage where a site visitor clicks on “email me” and a email pops up. How do I add a line of text to that email before the visitor starts typing?
Answers and Views:
Answer by Samwise
I am assuming that you’re writing this as a link, along the lines of
email me
You can add “search” parameters to a mailto: URL. If (and please note the IF here!) the user’s email client and browser support these parameters (which most do), these can specify some subject-line or body content.
Because this involves the user invoking his or her own email client, the user can delete or change this material. You don’t have control beyond that.
To add a line of text to the message body in the above example, we could write
email me
[That should all be on one line. I broke it after the question mark only so it’s more readable.]
Notice that special characters, including periods and spaces, have to be specially encoded for this to work. If you can run your text through a JavaScript escape() function, you’ll get the correct encoding.
Leave a Reply