开发者

Wordpress insert javascript into page text area

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(functi开发者_如何转开发on($){
        $.supersized({
            random : 1,
            slide_interval : 3000,
            transition : 3,
            transition_speed : 900,
            slide_links : 'blank',
        });
    });
</script>


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/


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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜