Reputation: 917
I have a problem. I need to make a link, if user click on that link users native email client will open with predefined message, but user must be able to select receiver address. I'm aware of mailto command but I couldn't find a way to allow user to select his own receiver address. Can someone help me with this?
Upvotes: 1
Views: 1950
Reputation: 27247
It's not clear what you want. Do you want the user to define the email in the browser or in their mail app? Here's a jsfiddle to show how to define it in the browser:
<p><input type="radio" name="email" value="[email protected]" />Apple</p>
<p><input type="radio" name="email" value="[email protected]" />Microsoft</p>
<p><input type="radio" name="email" value="[email protected]" />Linux</p>
<p><input type="radio" name="email" value="other" />Other: <input type="text" name="other_email" /></p>
<p><pre id="mailto_link"></pre></p>
$(function() {
$(':radio[name=email]').on('change', function() {
if ($(this).val() == 'other') {
$('#mailto_link').text('mailto:'+$('input[name=other_email]').val()+'?this+is+the+predefined+message');
}
else {
$('#mailto_link').text('mailto:'+$(this).val()+'?this+is+the+predefined+message');
}
});
$('input[name=other_email]').on('keyup', function() {
if ($(':radio[name=email]:checked').val() == 'other') {
$('#mailto_link').text('mailto:'+$(this).val()+'?this+is+the+predefined+message');
}
});
});
Upvotes: 0
Reputation: 1877
If you want to create default body copy without a default address you just ignore the address:
<a href="mailto:?body=This is the body copy.">Send email</a>
Upvotes: 3