JavaScript equivalent of href="mailto:emialaddress@gmail.com"

<tr height="20">
                  <td height="20" width="145"><font size="2" face="Arial">Email Address</font></td>
                  <td height="20" width="156"><a href="mailto:emailaddress@gmail.com"><font size="2" face="Arial">
                          <script type="text/javascript"> generateEmail("Email", "Address")</script> </font></a></td>
                </tr>

I have created a generate email function using javaScript to replace the email address in the content of the anchor tag (see above). Unfortunately, the plain text email address still resides in the href attribute. Id like to remove this using javaScript as well, any suggestions?
jdanaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Saqib KhanSenior DeveloperCommented:
Try...

                  <td height="20" width="145"><font size="2" face="Arial">Email Address</font></td>
                  <td height="20" width="156"><a href="javascript:generateEmail('Email', 'Address')"><font size="2" face="Arial">
                          <script type="text/javascript"> generateEmail("Email", "Address")</script> </font></a></td>
                </tr>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jason C. LevineNo oneCommented:
Hi jdana,

There is a great extension for Dreamweaver that will help immensely.  Download Super Email if you get a chance:

http://www.dmedia.net/dreamwarrior/superemail.html

Sample output is below:

<script language="JavaScript" type="text/javascript">
<!-- Begin
document.write('<a href=\"mailto:test'+ '@' + 'test.com\">');
document.write('Hi jdana</a>');
// End -->
</script>
0
leakim971PluritechnicianCommented:
Use :

location.href = "mailto:emialaddress@gmail.com";

Example with captcha :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
	function sendEmail() {
		var f = document.forms[0];
		if( (f.lname.value!="") && (f.fname.value!="") && (/^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/.exec(f.email.value)!=null) && (f.phone.value!="") && (f.comments.value!="") ) {
			if(document.forms[0].answer.value.toLowerCase() == images[i][document.forms[0].captcha.src].toLowerCase()) {
				var yourEmail = "mailto:youremail@domain.com";
				var subject = "&subject=YOUR SUBJECT HERE : " + f.fname.value + " " + f.lname.value + "( email: " + f.email.value + " ) / ( phone: " + f.phone.value + " )";
				var comments = escape(f.comments.value);
				location.href = yourEmail + subject + "&body="+ comments;
			}
			else {
				alert("brand not correct");
			}
		}
		else {
			alert("please complete the form with and check your email!");
		}
	}
	var images = [{"http://www.alpha-geek.fr/public/Apple/Logo_Apple.png":"Apple"}, {"http://www.couleurgeek.com/img/microsoft_logo.jpg":"Microsoft"}, {"http://www.chowen.com/images/ibm-logo.jpg":"IBM"}];
	var i = null;
	function captcha() {
		i = Math.floor( Math.random() * 3);
		for(url in images[i]) document.forms[0].captcha.src = url;
	}
</script>
</head>

<body onload="captcha();">
<form>
    First Name :&nbsp;<input type="text" name="fname"  /><br />
    Last Name :&nbsp;<input type="text" name="lname" /><br />
    Email Address :&nbsp;<input type="text" name="email" /><br />
    Phone Number :&nbsp;<input type="text" name="phone" /><br />
    Question/Comment :&nbsp;<textarea name="comments" cols="48" rows="6"></textarea><br />
    What's name of this brand :&nbsp;<img src="" name="captcha" width="96" />&nbsp; It's :&nbsp;<input type="text" name="answer" />
    <br />
    <input type="button" value="send email" onclick="sendEmail();" />
</form>
</body>
</html>

Open in new window

0
jdanaAuthor Commented:
Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.