• I currently run a small gaming blog and was interested in plugging JavaScript into the occasional post. There are times when I can get away with an embedded YouTube video, but sometimes I have to rely on sites that only offer embeddable videos via JavaScript.

    Right now, if I put JavaScript in a post the script is stripped when the post is served.

    I’ve checked the Plugin Database but got no results. The codex offers an option for putting things into posts but it isn’t realistic for my needs.

    Before I attempt writing a plugin I’m curious if anyone knows of an existing plugin or method for serving JavaScript videos in posts.

    Thanks in advance for any help.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Are you using the Rich Text Editor/wysiwyg to input posts? If so, it does strip code; disable it through wp-admin/Users/Your Profile, scroll to the bottom, uncheck the box on the left.

    And you can try surrounding your js with CDATA tags. I don’t know that that will work, but trying it couldn’t hurt.

    Thread Starter WildBil2Me

    (@wildbil2me)

    It’s not an issue of using the Rich Text Editor. Both in and out of the WYSIWYG editor JavaScript tags will be stripped – I also don’t use the WYSIWYG and never have.

    I’ll try with CDATA tags tonight but to be honest I’m not very familiar with them or their usage.

    Any other suggestions?

    Nope. I never insert code in posts. If I’m using adsense or something it’s in sidebar or footer.

    Could be some really complex escaping you could do, though again, I’m not much help, sorry.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    It’s wordpress doing this, actually. Here’s a quick plugin I cooked up a while back to change this functionality.

    Script Enabler

    Thread Starter WildBil2Me

    (@wildbil2me)

    Thanks Otto42, I knew that WordPress’ engine was stripping the tags and had assumed it was a security thing. I’ll check out your plugin and check back.

    Otto42,

    Plugin seems not working.

    (PS : Already posted in another topic )

    I’m trying to put Javascript in a post too. Actually what I want to do is illustrated perfectly at https://www.duffypov.com. They have galleries within posts that look to me like javascript, because they load a new image on click of a thumbnail without reloading the page. I’ve never done javascript but I just want this to work. My boss told me to find the grand poobah of wordpress and ask. Hopefully the grand poobah is out there. Help!

    The “perfect illustration” is password protected… in other words useless, so we have no idea what do you have in mind.

    I think WP strips off javascript any, to avoid security bugs such as cross site scripting.

    Javascript could access document.cookie, and so steal cookies. Sure, from your own site, but think about “shared” blogs.

    Additionally, a href.location(“https://www.ebay.com/buyitem.php?id=12334”); could you make buy strange things.

    Okay, the ebay thing probably still needs other things, but you get the idea…

    Don’t think. Read the documentation:
    https://codex.www.ads-software.com/Using_Javascript

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Placing JavaScript in Posts’ is closed to new replies.