2

我目前正在尝试执行以下操作:

触发器:单击选择列表中的名称。

操作:在当前窗口中打开 mailto-link,从而打开电子邮件客户端。

$(document).ready(function(){    

// Define click-event
$('option').click(function(){
    var mail = $(this).attr('value');
    window.open('mailto:'+mail, '_self');
    });

});

我也试过用这个代替window.open:

parent.location.href= 'mailto:'+mail;

但是,两者都只能在 Firefox 中工作,在 IE8 或 Chrome 中不会出现错误/结果。

有人知道问题可能是什么吗?

4

1 回答 1

1

这个怎么样(在IE8上对我有用)

$('option').change(function() {
   var target = 'mailto:' + $('option:selected', this).text();
   window.location=target;
});

可能有更好的方法可以做到这一点,但我在我的一个页面上使用了类似的东西。

如果电子邮件地址可以存储为选择选项值,请在末尾使用 .val() 而不是 .text()。

于 2010-03-23T14:00:19.377 回答