Okay, I realized that my blog was missing something. A way to get in touch with me privately - by email. I realized this because I wanted to thank a person who made a nice comment on my site, but I had no easy way to say that privately, as she had no email link on her site. Then I realized, I don't have one on my site either!
And there is a good reason I didn't want to put my email on my website. Spam Spider Bots. I didn't want to get a lot of spam because my email address was on a web page.
I was thinking that I remembered seeing on a web site a javascript option to obscure an email. I did quick google, but all the javascript examples I saw were just creating the email as a standard link with the document.write() option. In other words, the result was a machine readable string, although a little harder for a spider to decode.
I decided I wanted a more complex method, that didn't actually make the email address until a user clicks on the link. That meant javascript with a function. I've tested it in IE (v6). I'm sorry if it doesn't work for other browsers.
My basic idea is to hide the email in a split up string:
// mailme @2004 Keith Horowitz - GNU Opensource Copyright/Copyleft
function mailme() {
t='MaAaIaLaTaOa:aTaEaSaTa'
t=t+'@aYaAaHaOaOa.aCaOaMa'
d=''
for (a = 0; a < t.length; a+=2 ) d=d+t.substr(a,1)
location.href=d
}
Look at the uppercase letters in the string above. Then the for loop strips out every other character into the new string d. Then the magical, location.href gets passed the valid mailto string. This causes the default email client to start a new email with the encoded email address.
The you need a link:
<a href=# onclick="mailme();return false">EMail Me</a>
Now this probably won't keep out all spam. But hopefully it should keep spiders from adding me to thier lists.
And there is a good reason I didn't want to put my email on my website. Spam Spider Bots. I didn't want to get a lot of spam because my email address was on a web page.
I was thinking that I remembered seeing on a web site a javascript option to obscure an email. I did quick google, but all the javascript examples I saw were just creating the email as a standard link with the document.write() option. In other words, the result was a machine readable string, although a little harder for a spider to decode.
I decided I wanted a more complex method, that didn't actually make the email address until a user clicks on the link. That meant javascript with a function. I've tested it in IE (v6). I'm sorry if it doesn't work for other browsers.
My basic idea is to hide the email in a split up string:
// mailme @2004 Keith Horowitz - GNU Opensource Copyright/Copyleft
function mailme() {
t='MaAaIaLaTaOa:aTaEaSaTa'
t=t+'@aYaAaHaOaOa.aCaOaMa'
d=''
for (a = 0; a < t.length; a+=2 ) d=d+t.substr(a,1)
location.href=d
}
Look at the uppercase letters in the string above. Then the for loop strips out every other character into the new string d. Then the magical, location.href gets passed the valid mailto string. This causes the default email client to start a new email with the encoded email address.
The you need a link:
<a href=# onclick="mailme();return false">EMail Me</a>
Now this probably won't keep out all spam. But hopefully it should keep spiders from adding me to thier lists.
Comments