• Here’s hoping someone can help with this issue, please.

    I’ve recently installed a new instance of WP 2.5.1 and all was going well until I tried to trigger some JavaScript from within a post/page:
    <a href="javascript:functionName();">etc</a>

    When I try to save the page it will sit there for a while before timing out. The same thing happens if I just try to add the word JavaScript within the body of the text of a post.

    I disabled all plugins and reverted to the default skin just in case I’d added anything that could be causing this… Still the same problem.

    I’ve searched and searched, then searched some more trying to find a solution but haven’t found a thing so here I am.

    I’m getting close to missing my deadline on this so any help that anyone could offer would be greatly appreciated.

    TIA,

    Marc

Viewing 5 replies - 1 through 5 (of 5 total)
  • You can’t directly paste code like javascript into your post or page. Either put it into your template file (single.php or page.php) or find a plugin that lets you use javascript in posts/pages.

    Thread Starter seento

    (@seento)

    Thanks, but how do you actually make a call to the JavaScript within the post/page without an onclick or similar?

    Oh wait, you said find a plugin that lets you do that, I’ll have a search for that, thanks.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Actually, you can put javascript inside a post. No issue there with WP.

    However, if your host is running mod_security or something similar, then your host might block any of your attempts to do that.

    Thread Starter seento

    (@seento)

    Not sure about mod_security – that’s an Apache thing right?

    We’re running on a Sun One box, v7, with PHP running as a fastCGI plugin.

    No errors are being thrown when the page fails.

    Also there’s plenty of other JavaScript and PHP running on the same machine without issue.

    Looks like I’m going to have to change the original page functionality to operate without JavaScript – or maybe a php include to put the line of text I need in place though that sounds a bit convoluted.

    Any more help would be greatly appreciated.

    Thread Starter seento

    (@seento)

    Quite a messy workaround but, after adding the inline PHP plugin I can change this:
    <a href="javascript:void(0);" onclick="toggleLayer('OLGinstructions');"><em>Click here for download instructions</em></a>

    to this:

    <exec>
    echo("<a href=\"");
    echo("javas");
    echo("cript");
    echo(":void(0);\"");
    echo("onc");
    echo("lick");
    echo("=\"toggleLayer('OLGinstructions');\">");
    echo("<em>click here for instructions</em>");
    echo("</a>");
    </exec>

    I wanted to set up a list of strings which I included in my pre-header and echo those as needed on the page but it seemed they weren’t picked up by the plugin.

    Not ideal but hey, it works!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘2.5.1 – Can’t say JavaScript or onclick?’ is closed to new replies.