Title: How to insert Javascript in a post
Last modified: August 18, 2016

---

# How to insert Javascript in a post

 *  [lstelie](https://wordpress.org/support/users/lstelie/)
 * (@lstelie)
 * [21 years, 11 months ago](https://wordpress.org/support/topic/how-to-insert-javascript-in-a-post/)
 * Hello,
    I’d like to insert iun a post an encoded email in javascript form but
   this doesn’t seem to work (and this works well usually) The string is : `<script
   type="text/javascript" language="javascript">eval(unescape('%64%6f%63%75%6d%65%
   6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%
   78%2d%65%75%64%6f%72%61%2d%73%65%74%74%69%6e%67%73%40%74%69%64%62%69%74%73%2e%
   63%6f%6d%3f%73%75%62%6a%65%63%74%3d%41%44%44%22%20%63%6c%61%73%73%3d%22%67%6c%
   6f%62%61%6c%74%65%78%74%65%22%3e%78%2d%65%75%64%6f%72%61%2d%73%65%74%74%69%6e%
   67%73%40%74%69%64%62%69%74%73%2e%63%6f%6d%20%61%76%65%63%20%63%6f%6d%6d%65%20%
   73%75%6a%65%74%20%41%44%44%3c%2f%61%3e%27%29%3b'))</script>` But nothing is displayed
   in WP post (I use the same string in another website and I know this works perfectly).

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Mark (podz)](https://wordpress.org/support/users/podz/)
 * (@podz)
 * [21 years, 11 months ago](https://wordpress.org/support/topic/how-to-insert-javascript-in-a-post/#post-65654)
 * I can’t answer your question directly, but a more secure way is to have a contact
   form on your site.
    You can also add any additional information too. I’ve used
   one now for ages, and have yet to get a single spam to that email address. [http://www.stadtaus.com/en/php_scripts/formmail_script/](http://www.stadtaus.com/en/php_scripts/formmail_script/)
 *  Thread Starter [lstelie](https://wordpress.org/support/users/lstelie/)
 * (@lstelie)
 * [21 years, 11 months ago](https://wordpress.org/support/topic/how-to-insert-javascript-in-a-post/#post-65659)
 * [@podz](https://wordpress.org/support/users/podz/)
    I know I can use a form, 
   I do that for the “contact me” part of my resume website ([http://luc.saint-elie.com/contact.php](http://luc.saint-elie.com/contact.php))
   But for email adresses that are isinde texts I usaually use javascript encoding(
   in fact previously I used Smarty that provide this kind of functionnality) I 
   fail to get the correct javascript behavior with a text in WP and I’m searching
   the solution for that… Put the code I posted in an HTML; page and you’ll see,
   this works. Put it in a WP post..it doesn’t…
 *  [Beel](https://wordpress.org/support/users/beel/)
 * (@beel)
 * [21 years, 11 months ago](https://wordpress.org/support/topic/how-to-insert-javascript-in-a-post/#post-65663)
 * Yes, it would not – imagine the issues if one could place javascript in posts.
   You can probably come up with a filter to run any e-mail addresses through it
   and encode it using PHP.
 *  [planetphillip](https://wordpress.org/support/users/planetphillip/)
 * (@planetphillip)
 * [21 years, 10 months ago](https://wordpress.org/support/topic/how-to-insert-javascript-in-a-post/#post-65813)
 * lstelie:
    Would you be kind enough to post the solution so that others (me included)
   could learn? Thanks
 *  Anonymous
 * [21 years, 9 months ago](https://wordpress.org/support/topic/how-to-insert-javascript-in-a-post/#post-66156)
 * /
 *  [Ozh](https://wordpress.org/support/users/ozh/)
 * (@ozh)
 * [21 years, 9 months ago](https://wordpress.org/support/topic/how-to-insert-javascript-in-a-post/#post-66157)
 * all this seems pretty useless since WP has a built-in email obfuscation function.
   
   However a much simpler way to still use javascript is to use a function like :`
   function mailto (who,where,what) { if (who == undefined) {who = "ozh"}; if (where
   == undefined && who == "ozh") {where = "planetozh.com"}; if (what == undefined){
   quoi = ""}; location.target="_top"; location.href="mailto:"+who+"@"+where+"?subject
   ="+what; }  Then replace all your standard mailto links with : [mail me](https://wordpress.org/support/topic/how-to-insert-javascript-in-a-post/mailto()&apos;?output_format=md)
   or [mail Joe](https://wordpress.org/support/topic/how-to-insert-javascript-in-a-post/mailto("joe","isp.com","subject")?output_format=md)

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘How to insert Javascript in a post’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 6 participants
 * Last reply from: [Ozh](https://wordpress.org/support/users/ozh/)
 * Last activity: [21 years, 9 months ago](https://wordpress.org/support/topic/how-to-insert-javascript-in-a-post/#post-66157)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
