admin管理员组文章数量:1026620
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
2 Answers
Reset to default 2WordPress 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/
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
2 Answers
Reset to default 2WordPress 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/
本文标签: phpWordpress insert javascript into page text areaStack Overflow
版权声明:本文标题:php - Wordpress insert javascript into page text area - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745647860a2161133.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论