문제

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 work 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top