• 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)
  • 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/

    Thread Starter lstelie

    (@lstelie)

    @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 )
    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…

    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.

    lstelie:
    Would you be kind enough to post the solution so that others (me included) could learn?
    Thanks

    /

    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
    or
    mail Joe

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

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