Hello,
I'm posting this topic here because I'm using Tiger, and the solution works in Tiger, but I don't mind moving it to "General".
I usually place my email address as a link in the page footer and in the album information window, it's convenient for visitors. I realized today that this email address was present in clear text in the source code of the page and was "offered" to spambots
So, I decided to encode my email address in my albums. Google showed me different possibilities:
- encode the address by replacing some text by special characters, like "mailto:foo(at)boo(dot)com" or "mailto:foo@boo.com". I think that today, with the computing power available to spammers, that they can easily interpret the html and break such encoding, which makes this solution ineffective.
- I have seen solutions using CSS to recompose the email address on the screen (and in the links) without having the address in plain text in the source, but I found this approach a bit cumbersome.
- I saw (and adopted) a simpler solution with a little bit of Javascript: it uses links encoded in rot13 (see for example https://www.practicalecommerce.com/How-to-Hide-Email-Addresses-From-Spam-Bots).
If you want to set this up, here is the procedure to follow:
- You must first encode the mailto link in rot13 with an online encoder like https://cryptii.com/pipes/rot13-decoder. For example, "mailto:foo@boo.com" becomes "znvygb:sbb@obb.pbz"
- Then add the following code in the album settings in the Advanced / Custom code / Javascript section, reporting the encoded mailto link:
function decode(a) {
return a.replace(/[a-zA-Z]/g, function(c) {
return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
})
};
function openMailer(element, repl) {
var ra = decode("znvygb:sbb@obb.pbz"); // Place here the encoded mailto link
element.setAttribute("href", ra);
element.setAttribute("onclick", "");
if (repl) { element.firstChild.nodeValue = ra.replace("mai"+"lto:", ""); }
};
- Use this link in the Site / Footer / URL section, in place of a mailto link:
href="#" onclick='openMailer(this);
Additionally, I use the link below in the album information box. Using the 2nd parameter of
openMail allows to replace
at screen "click here" by the real mail address when the link is clicked.
Contact: <a id="email" href="#" onclick='openMailer(this, 1);'>click here</a>
It's done ! That way, the links works as expected, but the email address is no present in the code source of the page!
Now, maybe jAlbum and/or Tiger can help us improve this subject?
Edited by: phil44 on 11 Sep 2023, 20:37. Reason: reformatting
Edited by: phil44 on 21 Sep 2023, 18:45 Add missing call to openMailer in the last example
Edited by: phil44 on 27 Oct 2023, 19:43: Fix www.practicalecommerce.com url which had a space in it, leading to 404 error.