Вы здесь

Скрыть e-mail через js - Hide Email JavaScript

Статейка на инглише, но там все ясно вроде как. Это сложный вариант.

As a rule I never write an actual email address on a web page. Now, please note that I’m not talking about the page which is displayed, but rather the one that is written. The HTML part; what’s made in NotePad or whatever it is you use to write your mark-up. The part that is crawled by spiders looking for stuff like that. It’s all about privacy and trying to limit spam intake.

Search spiders key on certain things when crawling a page looking for email addresses. Specifically they look for…

  • mailto:
  • @ (at symbol)
  • Combination of items or strings

I’m pretty sure the “a” or anchor and “.” play a role depending on the spider’s abilities.

So if you want to put an actual email address on your site, how do you avoid having it crawled, detected, and ultimately exploited? (If you’re looking for cheap software, budget Viagra, and Hot Women, then ignore all of that which follows.)

One way is to do a simple character replacement by way of converting key — or even all — characters into HTML-readable entities using a ISO Latin 1 Character Entities and HTML Escape Sequence Table.

So, in other words, instead of writing:
myemail@mydomain.com

You can put this instead:

myemail  (myemail) @ (@ “at” symbol) mydomain (mydomain) . (. “.” dot) com (com)

Doing it this way adds a lot of code, but it is fairly accessible. But there is also a JavaScript option using document.write, as follows:

1) You first want to create a JavaScript document which contains this code:

<!--
function eml_coder(account,domain,dotwhat)
{
document.write('<a href="mailto:'+account+'&#64;'+domain+'&#46;'+dotwhat+'?subject=Email%20Test" title="Email Test">'+account+'&#64;'+domain+'&#46;'+dotwhat+'</a>');
}
//-->

Save it as “eml_coder.js

2) In the <head></head> of the web document in which this code will be used, place a link to the script as follows:

<script src="eml_coder.js" type="text/javascript"></script>

3) Now you need to enter the data (in bold) and place this where ever you want the email address to appear on the page:

<p><script type="text/javascript"> »»
eml_coder("freddy","testing","com")</script></p>

The HTML output (code written to the page specific to that visitor) will be:

<a href="mailto:freddy&#64;testing&#46;com?subject=Email%20Test" title="Email Test">freddy&#64;testing&#46;com</a>

А вот версия облегченная пока суд да право:

<script language="javascript">
<!--
var part1 = "name";
var part2 = "domen.ru?subject=тема письма";
var part3 = "Отправьте письмо";
document.write('<a href="mai' + 'lto:' + part1 + '@' + part2 + '">');
document.write(part3 + '</a>');
// -->
</script>