• Hello! I want to run a JavaScript inside a WP post:

    <span class="aff" onclick="GoTo('URL')" target="blank">text</span>

    When I add this code to a post the event doesn’t work and I have an error when I look at the console: “Uncaught ReferenceError: GoTo is not defined at HTMLSpanElement.onclick”.

    Please, help to fix the issue. Thank you in advance!

    • This topic was modified 7 years, 6 months ago by Max.
Viewing 2 replies - 1 through 2 (of 2 total)
  • AddWeb Solution

    (@addweb-solution-pvt-ltd)

    You might have missed something. This should work properly if you have followed the below steps:

    – Put your <span> tag html code in “Text” tab of post editor.

    – And your javascript function in any .js file which must be included in header or footer file.

    Hope this will help you.

    Thread Starter Max

    (@wilhard)

    No, this will not of any help to me(.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How do I add onclick event with go to into a post?’ is closed to new replies.