views:

311

answers:

1

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?

+1  A: 

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.

odavy
That almost works, have to change the option-selector to "select", thanks a bunch :)
Rakward
Doh! Yes, it should be the name of the select, not the option. Apologies :)
odavy
Also, if you tag your question with the tag jQuery, you may get some more attention for it...
odavy