Forums

Placing JavaScript in Posts (11 posts)

  1. WildBil2Me
    Member
    Posted 2 years ago #

    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.

  2. vkaryl
    Member
    Posted 2 years ago #

    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.

  3. WildBil2Me
    Member
    Posted 2 years ago #

    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?

  4. vkaryl
    Member
    Posted 2 years ago #

    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.

  5. Otto42
    Moderator
    Posted 2 years ago #

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

    Script Enabler

  6. WildBil2Me
    Member
    Posted 2 years ago #

    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.

  7. wifiman01
    Member
    Posted 2 years ago #

    Otto42,

    Plugin seems not working.

    (PS : Already posted in another topic )

  8. banabliss
    Member
    Posted 2 years ago #

    I'm trying to put Javascript in a post too. Actually what I want to do is illustrated perfectly at 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!

  9. moshu
    Member
    Posted 2 years ago #

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

  10. mike13
    Member
    Posted 2 years ago #

    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("http://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...

  11. moshu
    Member
    Posted 2 years ago #

    Don't think. Read the documentation:
    http://codex.wordpress.org/Using_Javascript

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags