2

I'm trying to add some JavaScript into one of my Wordpress pages. When I change the text area to HTML mode and paste in the JavaScript then save my changes. It does not appear on the page itself. Can someone please help me allow JavaScript in the default Wordpress page text editor?

The JavaScript that I am trying to input is:

<script type="text/javascript">
 jQuery(function($){
 $.supersized({
 random : 1,
 slide_interval : 3000,
 transition : 3,
 transition_speed : 900,
 slide_links : 'blank',
 });
 });
</script>
YakovL
8,45813 gold badges74 silver badges117 bronze badges
asked Sep 10, 2011 at 9:56
1

2 Answers 2

2

WordPress is really picky about how you do the newlines and it will sometimes place <p> tags in there which will mess up JavaScript code. I would recommend looking at the source after you make the post and see if any of the <p> tags got incorporated. If so, go back and delete the white-spacing in that area and try again.

In the worst case, you can always use the Raw HTML plugin which will render the raw code for you:

http://wordpress.org/extend/plugins/raw-html/

answered Sep 10, 2011 at 10:00
Sign up to request clarification or add additional context in comments.

2 Comments

When I looked at my source, I noticed that wordpress has added CDATA and it was preventing the javascript from loading. This was also due to me, after changing the text area from visual to HTML and then changing the text area back to visual and clicking the update button.
Yea...weird things do happen when you switch back and forth from the html and visual tabs. I strictly use the html tab myself to avoid the extra markup.
0

You, or others viewing this question, might also want to try my plugin which enables support for inline JavaScript and JavaScript code blocks in the HTML editor tab. You don't have to use a shortcode or special markup and you can continue to use the TinyMCE wysiwyg editor without worrying too much about losing the content... If you delete everything in the Visual editor, you'll lose the code block, but edits, additions and targeted deletions of content are fully compatible.

It also preserves whitespace and indentation of HTML code when you switch between the HTML and Visual tabs among a few other minor features.

http://wordpress.org/extend/plugins/preserved-html-editor-markup/

answered Sep 10, 2012 at 20:56

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.