• Hello everyone!

    My problem is the following: whenever I want to insert this
    <a href="Javascript: history.back(-1);">? Back</a>
    into a WordPress page, it is always edited by WP into this:
    <a href="https://audrey-tautou.org/Javascript:
    %20history.back%28-1%29;">? Back</a>

    (site is Audrey-Tautou.org)

    Does anyone know why that simple Javascript is not accepted? Anything I can do?

    Thanks,
    Manila

Viewing 10 replies - 1 through 10 (of 10 total)
  • Hello

    Seems to work for me, where are you pasting it, in a post/page or into a theme file?

    Thread Starter manila

    (@manila)

    Hi!
    I want to post it in a page.

    I was having problems running JS from within the loop like that, but there may be a plugin that lets you do something like this. Also, try putting the JS in the page template itself, rather than putting it in the content of the post. This page has a lengthy article on the subject: https://codex.www.ads-software.com/Using_Javascript

    Thread Starter manila

    (@manila)

    Thanks! I put the JS into the page template and now everything works ??

    Another question: Why does WP also edit the
    out? I can put as many
    or <br> into a page template, it is always removed o__?

    It’s editing tags that are in the template or the post? If it’s in the post, that’s part of the reason JavaScript and PHP won’t work well in a post. WP automatically escapes certain characters, such as breaks and apostrophes.

    Thread Starter manila

    (@manila)

    It’s editing tags in a post/page. Whenever I put a <br>-tag into a post/page and I update it, it is not there anymore later.

    Anything I can do?

    Just hit Enter. That gives a carriage return (line break) in the post automatically.

    Thread Starter manila

    (@manila)

    Yes, but only once. If I click “Enter” several times for more space between things, it won’t work.

    Why not use CSS? Put the next bit of text in a div with padding-top set to something like 2em or whatever.

    Thread Starter manila

    (@manila)

    Thanks jonlandrum, I’m gonna check that out ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘WP doesn’t accept “Javascript: history.back(-1)”’ is closed to new replies.