FranticTom Posted October 26, 2016 Share Posted October 26, 2016 Hi Folks! In order to avoid spammers' crawling bots, I want to hide my store's email address using Javascript. For example, I'd like to follow a method similar to this: <!-- // http://lists.evolt.org/archive/Week-of-Mon-20040202/154813.html --><script type="text/javascript"> function gen_mail_to_link(lhs,rhs,subject) { document.write("<a href=\"mailto"); document.write(":" + lhs + "@"); document.write(rhs + "?subject=" + subject + "\">" + lhs + "@" + rhs + "<\/a>"); } gen_mail_to_link("john.doe","example.com","Feedback about your site...");</script> Which I found here: http://stackoverflow.com/questions/483212/effective-method-to-hide-email-from-spam-bots Has anyone found a module or other clean way of doing this? Help much appreciated, Tom Link to comment Share on other sites More sharing options...
FranticTom Posted October 27, 2016 Author Share Posted October 27, 2016 Ok, while I'd have preferred an automated way of doing this, such as having PrestaShop automatically obfuscating email fields (e.g. in Contact Information Block) automatically, I was able to rewrite the whole Contact Information Block in HTML and JavaScript so the email is obfuscated. To do so, I bought one of the custom HTML modules. Make sure you escape characters while doing so. Here's my code, which accurately replaces the Contact Information Block: <section id="block_contact_infos" class="footer-block col-xs-12 col-sm-4"> <div> <h4>Store Information</h4> <ul class="toggle-footer" style=""> <li><i class="icon-map-marker"></i>Frenzy Sàrl<br />Clos-du-Vernay 36<br />1677 Prez-vers-Siviriez<br />Switzerland</li> <li><i class="icon-phone"></i>Call us now: <span>+41 32 510 97 34</span></li> <li><i class="icon-envelope-alt"></i>Email: <span id="obfEmail"> </span></li> </ul> <script type="text/javascript"> function ObfuscateEmail(lhs,rhs,subject) { a="<a href=\"mailto"; b=":" + lhs + "@"; c=rhs + "?subject=" + subject + "\">" + lhs + "@" + rhs + "<\/a>"; return a + b + c; } document.getElementById("obfEmail").innerHTML=ObfuscateEmail("sales","healthygoodies.ch","Feedback about your site..."); </script> <noscript> <em>Email address protected by JavaScript. Activate JavaScript to see the email.</em> </noscript> </div></section> This means you'll have to do this for each language. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now