[thelist] Js hiding email address

Chris Marsh chris at ecleanuk.com
Thu Feb 27 08:46:01 CST 2003


Benjer

> <code>
> <script language=javascript>
> <!--
> var username = "benjer";
> var hostname = "macmail.com";
> document.write("<a href=" + "mail" + "to:" + username +
> "@" + hostname + '"'+"onMouseOut='MM_swapImgRestore()'
> onMouseOver='MM_swapImage('email','','images/email_f2.gif',1)'
> >" + "<img src='images/email.gif' alt='email' name='email'
> width='31' height='16' border='0'>" + "</a>") //--> </script> </code>
>
> I always get in a bit of a muddle with ³¹² and Œ²¹ can anyone
> help clear this up for me.

How about:

<script>
var username = "benjer";
var hostname = "macmail.com";
var email = username + "@" + hostname;
var link = "<a href='mailto:" + email + "' ";
var mover = "MM_swapImage(\"email\",\"\",\"images/email_f2.gif\",1)";
var mout = "MM_swapImgRestore()";
var img = "<img src='images/email.gif' alt='email' name='email'
width='31' height='16' border='0' />";
link += "onmouseover='" + mover + "' ";
link += "onmouseout='" + mout + "'>";
link += img;
link += "</a>";
document.write(link);
</script>

You can condense this code, but I left it expanded like this to simplify
what's going on. You'll note that var mover contains escaped double
quotes. I think that this is the only place you'll need to escape
quotes.

HTH

Regards

Chris Marsh




More information about the thelist mailing list