Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:14
Javascript email address
Poster: heavener
Dated: Monday August 23 2004 - 19:04:38 BST
I use a snippet of javascript (see below) every time I want to display my email address on my web site.This seems to eliminate spammers spidering the address.
Unfortunately, the script doesn't fit into the Milonic menus, even with the added flexibility of version 5.
Is there any way I can add this kind of parsing to the Milonic script?
<script language="Javascript">
a_mail_name = "heavener"
a_mail_domain = "heavenr.com"
document.write("<a href='" + a_mail_name + " __at__ " + a_mail_domain + "'>");
document.write("<span style='color:Maroon;text-decoration:none;'>");
document.write(a_mail_name + " __at__ " + a_mail_domain);
document.write("</span></a>");
</script>
The web site/menu is located at http://www.heavenr.com
Poster: Andy
Dated: Tuesday August 24 2004 - 11:13:52 BST
Hi,
What you need to do is put your code inside a function with a return value of your email address.
Here's the function:
Code:
function myEmail()
{
a_mail_name = "heavener"
a_mail_domain = "heavenr.com"
retEmail="<a href='" + a_mail_name + " __at__ " + a_mail_domain + "'>"
retEmail+="<span style='color:Maroon;text-decoration:none;'>"
retEmail+=a_mail_name + " __at__ " + a_mail_domain
retEmail+="</span></a>"
return retEmail
}
{
a_mail_name = "heavener"
a_mail_domain = "heavenr.com"
retEmail="<a href='" + a_mail_name + " __at__ " + a_mail_domain + "'>"
retEmail+="<span style='color:Maroon;text-decoration:none;'>"
retEmail+=a_mail_name + " __at__ " + a_mail_domain
retEmail+="</span></a>"
return retEmail
}
This can go inside the menu_data.js file but the function needs to be included before you call it. So the best place to put this function is at the top of your data file.
To call this function, try this:
Code:
aI("text="+myEmail()+";type=html;");
Hope this helps
Andy
Poster: heavener
Dated: Wednesday August 25 2004 - 0:46:02 BST
Your code snippet works great ... except the mouseover text color does not change. The URL is http://www.heavenr.com
Poster: Andy
Dated: Wednesday August 25 2004 - 9:50:39 BST
If you remove the HTML for the span and let the menu control the colors, it will work as expected. You also need to remove the type=html; part
Here's another snippet.
Code:
function myEmail()
{
a_mail_name = "heavener"
a_mail_domain = "heavenr.com"
return a_mail_name+" __at__ "+a_mail_domain
}
{
a_mail_name = "heavener"
a_mail_domain = "heavenr.com"
return a_mail_name+" __at__ "+a_mail_domain
}
then your aI() string should look like this:
Code:
aI("text="+myEmail()+";url="+myEmail());
If you have access to PHP you could also use the encoding function:
Code:
function emailEnc($email)
{
$retEmail="";
for($a=0;$a<strlen($email);$a++)$retEmail.="&#".ord($email[$a]).";";
return $retEmail;
}
{
$retEmail="";
for($a=0;$a<strlen($email);$a++)$retEmail.="&#".ord($email[$a]).";";
return $retEmail;
}
Cheers
Andy