1

I use the following jQuery code to hide my email (name.family@gmail.com) on my website:

$(document).ready(function() {
  var n = "name";
  var f = "family";
  var d = ".";
  var t = "gmail";
  var l = "com";
  var r = 'mailto:' + n + d + f + '@' + t + d + l;
  $('.hide-email').attr('href',r).html(r);
});

Does this actually stop spambots from collecting the email address? They also request my web page, load it and then analyze it for email addresses, right? And after the web page has been loaded, jQuery would produce the real email address. The only way to really protect my email is with a captcha, which is not so user-friendly...

Am I wrong?

UPDATE: The main question for me is - does the "hide email with JS or jQuery" method work at all?

user1414745
  • 1,317
  • 6
  • 25
  • 45

2 Answers2

1

does the "hide email with JS or jQuery" method work at all?

Yes, it does (usually). While in theory a spam bot could evaluate the Javascript just like a browser does, they don't usually do that in practice. Most of the bots don't even resolve character entity references (the &...; thingies), which is not even JS, but pure HTML. That is because collecting email addresses for spamming purposes relies on mass, not quality. They make it quick and dirty and will just look for the @ character. They most probably ignore any Javascript.

The drawback is, of course, a regular user has to enable Javascript to see the address.

T-Bull
  • 2,136
  • 2
  • 15
  • 17
0
function fixEmail ($) {
    var $$ = 0;
    return $.replace(/.../g, function ($) {
        return String.fromCharCode ((parseInt($, 36) / 15 + 5) / (++$$))
    });
}
function encryptEmail (mail) {
    var pos = 0;
    return mail.replace(/./g, function (a) {
        return ((a.charCodeAt(0) * (++pos) - 5) * 15).toString(36)
    });
}

$(function () {
    $('.hide-email').attr('href', fixEmail('17c26r3l64xx6nl7nf4n3a19ago7clcsuglxejchlrjdxjxxjtc9ixlpopmxqfo')).html('Email me');
});

Maybe something like this .

Jixun
  • 140
  • 10