Open mailto after click in IE8/Chrome
I'm currently trying to do the following:
Trigger: click on a name in a select list.
Action : open mailto-link in current window, thus opening an email client.
$(document).ready(function(){
// Define click-event
$('option').click(function(){
var mail = $(this).attr('value');
window.open('mailto:'+mail, '_self');
});
});
I've also tried using this instead of window.open:
parent.location.href= 'mailto:'+mail;
However, both w开发者_JS百科ork only in firefox, get no errors/results in IE8 or Chrome.
Anybody know what the problem could be?
How about this (works for me on IE8)
$('option').change(function() {
var target = 'mailto:' + $('option:selected', this).text();
window.location=target;
});
There's probably a better way to do this but I use a similar thing on one of my pages.
If the email address can be stored as the select option value, use .val() instead of .text() at the end.
精彩评论