php - Wordpress insert javascript into page text area - Stack Overflow

I'm trying to add some JavaScript into one of my Wordpress pages. When I change the text area to H

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>

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>
Share Improve this question edited Aug 6, 2018 at 18:07 YakovL 8,40513 gold badges73 silver badges113 bronze badges asked Sep 10, 2011 at 9:56 cvandalcvandal 7946 gold badges19 silver badges32 bronze badges 1
  • Take a look at this document: codex.wordpress/Using_Javascript#Javascript_in_Posts – GianluKa Commented Sep 10, 2011 at 9:59
Add a ment  | 

2 Answers 2

Reset to default 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 remend 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/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 patible.

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/extend/plugins/preserved-html-editor-markup/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745647862a4638079.html

相关推荐

  • php - Wordpress insert javascript into page text area - Stack Overflow

    I'm trying to add some JavaScript into one of my Wordpress pages. When I change the text area to H

    22天前
    60

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信