Support » Installing WordPress » JavaScript email link

  • Resolved Jonathan Landrum


    Hello all,

    I ran across a way to use javascript to place an email link on a page, rather than an anchor. The reasoning behind this is that crapbots will have a tougher time at harvesting the email address this way. Here’s the script:

    <script type='text/javascript'>var a = new

    Array(' "MAILTO:" in ASCII characters ',' first 7 characters of your address ',' second 7 characters of your address ',' et cetera... ');document.write("<a

    <noscript><img src=" location of the image of your email address " title=" img title "></noscript>

    After Array(' enter your email address seven characters at a time between single quotes, no spaces, separated by a comma. Then, after href=' enter +a[0]+a[1]+a[2]… until you’ve entered all the groups required to fit your address. Do the same between the anchor tags for the name, or enter a set of words. The <noscript> tags are for people who’ve disabled javascript.

    Now, here’s the question. How do I use javascript in WP? When I placed the code on my “contact” page it didn’t show up. There was just a blank there. Any takers?


Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator James Huff


    Volunteer Moderator 🚀

    You should just be able to place it anywhere in your sidebar or footer and have it appear. I think something’s wrong with your javascript, but I’m no js coder. What I would suggest, since you are going for a javascript email link, is that you go for a javascript encrypted email link:

    Hey macmanx, no luck. I checked FF to make sure I have javascript enabled, and I do. I also added a <noscript> tag after the script Enkoder created and it still didn’t work. I’m adding this script to a separate page I created in wp-admin called “Contact Me”. Perhaps I should just have the Contact Me link go directly to my email address, insead of opening a new page. I’ll try doing that and sticking it in the footer, like you suggested.


    Yeah, that did it. For some reason, it wouldn’t let me put the script in the page. I checked the source of the page and the script was there, no problem. I’ll bet, though, WP “cleaned” the script by adding breaks and paragraphs at every new line, or something like that 🙂
    Thanks for your help.


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘JavaScript email link’ is closed to new replies.