
Whenever I enter Javascript tags like <script>...</script> in the WordPress MU posts, they will disappear. The same thing is with the <object>..</object> and other HTML tags. I understand they got stripped by some filter codes due to the consideration of web security. But I need such tags badly since I have a lot of YouTube videos need to be embedded which come with <object> tags, and some Javascript tags too (like the countdown image from Ubuntu in my previous post).
What are the solutions? I could not find any official solutions from the support forum of WordPress MU website. Someone recommends to put the Javascript text in sidebar, or download some plugins to do so. Since I need to show videos in my posts, the widget sidebar one can not be good to me. I decide to change filter code file which was not my best choice though.
The file is located in /wp-include folder and the name is kses.php.
The quick way is to comment out the following two lines at the end of this file:
add_action(‘init’, ‘kses_init’);
add_action(‘set_current_user’, ‘kses_init’);
But in this way, all new posts and comments will be able to have powerful HTML tags like <script><object>. I trust myself since I am the owner and author for all my blogs in WordPress MU, but I do not trust all comment users.
So I guess it will be a better way to only add tags in the global variable of $allowedposttags. In line 184 of kses.php file, I added the following lines to allow my posts to have <script><object> tags.
//added by WebGuru on 2007-10-06
‘script’ => array(
‘type’ => array(),
‘src’ => array()
),
‘noscript’ => array(),
‘object’ => array(
‘height’ => array(),
‘width’ => array(),
‘type’ => array(),
‘data’ => array(),
‘allowfullscreen’ => array(),
‘id’ => array()
),
‘param’ => array(
‘name’ => array(),
‘value’ => array()
),
‘embed’ => array(
‘width’ => array(),
‘height’ => array(),
‘type’ => array(),
‘src’ => array()
)
With the above addition, it is enough for the purposes of posting YouTube videos and other Javascript codes. Of course, if someone can make a plugin to do so instead of modifying the core fiels please let me know and I would like to use this plugin.
No tag for this post.
不错不错How to enable or use Javascript and Flash embed in WordPress MU …
[Reply]
http://www.thosecodes.com for a tutorial on inserting SWF images. You should be able to post your raw code into your “code” view of creating a post.
[Reply]
Thanks for the post, i enjoyed reading it. blogging is not as easy as many think it is, it’s hardwork. any how thanks.
[Reply]
Hey, I came across this post while searching for help with JavaScript. I’ve recently changed browsers from Safari to Firefox 3.2. Just recently I seem to have a issue with loading JavaScript. Everytime I browse page that needs Javascript, my browser freezes and I get a “runtime error javascript.JSException: Unknown name”. I can’t seem to find out how to fix the problem. Any help is greatly appreciated! Thanks
[Reply]
Wow I cant look at who is making all these crazy posts. Your site is excellent and it attracts a lot of amounts of these types people. all the best and keep up for the work!
[Reply]
we do a lot of stuffs for home improvement since our house is getting old already.”;”
[Reply]
Thank you for this post, just what I am looking for. Really appreciate it.
Cheers.
[Reply]