djfenom
asked on
Using select menu to open mailto link
I've got a select menu with a list of names and emails, when you click one I want the email client to open up as it would on a normal mailto link. The problem is it keeps opening up a new window and the email client!
I've tried the following code with preventDefault and return false but to no avail!
Thanks in advance.
Chris
I've tried the following code with preventDefault and return false but to no avail!
Thanks in advance.
Chris
$(document).ready(function(){
$("#contacts").change(function() {
if (this.value != "") {
location.href='mailto:'+$(this).val();
}
});
});
Your codes seems to be working fine for me.
i have used.
<script src="jquery-1.3.2.min.js"> </script>
<script type="text/javascript">
$(document).ready(function (){
$("#contacts").change(func tion() {
if (this.value != "") {
location.href='mailto:'+$( this).val( );
}
});
});
</script>
<select id="contacts">
<option value="abcd@xyz.com">abcd< /option>
<option value="abcd1@xyz.com">abcd 1</option>
<option value="abcd2@xyz.com">abcd 2</option>
</select>
this is working as expected and i do not see any additional window. I have checked this in ie6 7 and ff
i have used.
<script src="jquery-1.3.2.min.js">
<script type="text/javascript">
$(document).ready(function
$("#contacts").change(func
if (this.value != "") {
location.href='mailto:'+$(
}
});
});
</script>
<select id="contacts">
<option value="abcd@xyz.com">abcd<
<option value="abcd1@xyz.com">abcd
<option value="abcd2@xyz.com">abcd
</select>
this is working as expected and i do not see any additional window. I have checked this in ie6 7 and ff
ASKER
I've got this:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function (){
$("#contacts").change(func tion() {
if (this.value != "") {
location.href='mailto:'+$( this).val( );
}
});
});
</script>
<select name="contacts" id="contacts">
<option value="" selected="selected">Contac t Us:-</option>
<option value="blah@blah.co.uk">Bl ah</option >
<option value="blah@blah.co.uk">Bl ah</option >
<option value="blah@blah.co.uk">Bl ah</option >
<option value="blah@blah.co.uk">Bl ah</option >
<option value="blah@blah.co.uk">Bl ah</option >
</select>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function
$("#contacts").change(func
if (this.value != "") {
location.href='mailto:'+$(
}
});
});
</script>
<select name="contacts" id="contacts">
<option value="" selected="selected">Contac
<option value="blah@blah.co.uk">Bl
<option value="blah@blah.co.uk">Bl
<option value="blah@blah.co.uk">Bl
<option value="blah@blah.co.uk">Bl
<option value="blah@blah.co.uk">Bl
</select>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER