&&正在破坏 WordPress 中的页面
我将此添加到我的 WordPress 页面
if (script.readyState && script.onload!==null){
script.onreadystatechange= function () {
if (this.readyState == 'complete') mce_preload_check();
}
}
和 &&
正在转向
if (script.readyState && script.onload!==null){
我将其粘贴到 WordPress HTML 视图中,我确保这没问题,但 WordPress 一直显示此内容。如何解决这个问题?
I added this to my WordPress page
if (script.readyState && script.onload!==null){
script.onreadystatechange= function () {
if (this.readyState == 'complete') mce_preload_check();
}
}
and the &&
is being turned to
if (script.readyState && script.onload!==null){
I pasted this in WordPress HTML view and I made sure this was fine but WordPress keeps displaying this. How to address this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要禁用 WP 的自动格式化。即使在 html 编辑器中,WP 也会自动格式化,并且空格和换行符会破坏您的 javascript。
使用此插件 http://wordpress.org/extend/plugins/wp-no-format /
更新 4/08/2015:插件已过时,但对我来说仍然有效。
这也有效:将插件直接添加到functions.php并将你的 JavaScript 在
和
标签
添加到functions.php 文件:
You need to disable WP's autoformatting. WP will auto format even in the html editor, and the spaces and line breaks will break your javascript.
Use this plugin http://wordpress.org/extend/plugins/wp-no-format/
Update 4/08/2015: plugin is dated but still works for me.
This also works: add the plugin directly to functions.php and bracket the your javascript in
<!-- noformat on -->
and<!-- noformat off -->
tagsAdd to functions.php file:
另一种选择是制作短代码。在此示例中,只有包含属性
x
和y
的短代码才会被打印,例如:[myscript x="10" y="20" ]
。我正在使用一个简单的脚本,该脚本显示带有属性值的 JS 警报对话框。Another option is to make a shortcode. In this example, the shortcode will only be printed if it contains the attributes
x
andy
, e.g.:[myscript x="10" y="20"]
. I'm using a simple script that shows a JS alert dialog with the attributes values.确保以下行(通过内联 PHP(您需要一个插件)或在“functions.php”中)在您的页面上执行:
Make sure the following lines (either via inline PHP (you need a plugin for that) or in "functions.php") are being executed on your page:
将此代码片段添加到您的脚本中
Add this code snippet to your script