Solved

Using select menu to open mailto link

Posted on 2010-09-23
4
739 Views
Last Modified: 2012-05-10
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
$(document).ready(function(){
	$("#contacts").change(function() {
		if (this.value != "") {
			location.href='mailto:'+$(this).val(); 
		}
	});
});

Open in new window

0
Comment
Question by:djfenom
  • 2
  • 2
4 Comments
 

Author Comment

by:djfenom
ID: 33742128
It's only in IE by the way!
0
 
LVL 14

Expert Comment

by:Dushyant Sharma
ID: 33742330
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(function() {
                    if (this.value != "") {
                        location.href='mailto:'+$(this).val();
                    }
                });
            });

        </script>
        <select id="contacts">
            <option value="abcd@xyz.com">abcd</option>
            <option value="abcd1@xyz.com">abcd1</option>
            <option value="abcd2@xyz.com">abcd2</option>

        </select>

this is working as expected and i do not see any additional window. I have checked this in ie6 7 and ff
0
 

Author Comment

by:djfenom
ID: 33742726
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(function() {
            if (this.value != "") {
                  location.href='mailto:'+$(this).val();
            }
      });
});
</script>
<select name="contacts" id="contacts">
            <option value="" selected="selected">Contact Us:-</option>
            <option value="blah@blah.co.uk">Blah</option>
            <option value="blah@blah.co.uk">Blah</option>
            <option value="blah@blah.co.uk">Blah</option>
            <option value="blah@blah.co.uk">Blah</option>
            <option value="blah@blah.co.uk">Blah</option>
          </select>
0
 
LVL 14

Accepted Solution

by:
Dushyant Sharma earned 500 total points
ID: 33743193
This too  is working fine for me, as it should be. on changing the select option it opens up the email client.
No other window opening up.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question