Wordpress 将 javascript 插入页面文本区域 [英] Wordpress insert javascript into page text area

查看:25
本文介绍了Wordpress 将 javascript 插入页面文本区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些 JavaScript 添加到我的 Wordpress 页面之一.当我将文本区域更改为 HTML 模式并粘贴到 JavaScript 中时,然后保存我的更改.它不会出现在页面本身上.有人可以帮我在默认的 Wordpress 页面文本编辑器中允许 JavaScript 吗?

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?

我尝试输入的 JavaScript 是:

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>

推荐答案

WordPress 对于换行的方式非常挑剔,它有时会在其中放置 <p> 标签,这会搞砸JavaScript 代码.我建议您在发帖后查看源代码,看看是否有任何 <p> 标签被合并.如果是这样,请返回并删除该区域的空格并重试.

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.

在最坏的情况下,您始终可以使用原始 HTML 插件为您呈现原始代码:

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/

这篇关于Wordpress 将 javascript 插入页面文本区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆