Javascript 为什么色盒加载不正确?
我得到的错误是: $未定义 第8行 即:Javascript 为什么色盒加载不正确?,javascript,jquery,drupal,drupal-6,colorbox,Javascript,Jquery,Drupal,Drupal 6,Colorbox,我得到的错误是: $未定义 第8行 即: $.colorbox({html:'<p>TEST TEST</p>'}); $.colorbox({html:'testtest'}); 这是页面呈现的方式: <script type="text/javascript" src="/sites/all/modules/jquery_update/replace/jquery.min.js?Y"></script> <script type="t
$.colorbox({html:'<p>TEST TEST</p>'});
$.colorbox({html:'testtest'});
这是页面呈现的方式:
<script type="text/javascript" src="/sites/all/modules/jquery_update/replace/jquery.min.js?Y"></script>
<script type="text/javascript" src="/misc/drupal.js?Y"></script>
<script type="text/javascript" src="/sites/all/modules/fivestar/js/fivestar.js?Y"></script>
<script type="text/javascript" src="/sites/all/modules/extlink/extlink.js?Y"></script>
<script type="text/javascript" src="/sites/all/modules/signwriter/signwriter.js?Y"></script>
<script type="text/javascript" src="/sites/all/modules/thickbox/thickbox.js?Y"></script>
<script type="text/javascript" src="/sites/all/modules/ubercart/uc_roles/uc_roles.js?Y"></script>
<script type="text/javascript" defer="defer" src="/sites/all/modules/admin_menu/admin_menu.js?Y"></script>
<script type="text/javascript" src="/sites/all/libraries/jquery/colorbox/jquery.colorbox.js?Y"></script>
<script type="text/javascript" src="/sites/all/modules/mysite/mysite_module/js/sasapp.js?Y"></script<--($.colorbox({html:'<p>TEST</p>'});)
您没有正确包含jQuery,请检查源代码并确认您的第一个脚本src实际上就是jQuery源代码。您没有正确包含jQuery,请检查源代码并确认您的第一个脚本src实际上是jQuery源代码。jQuery有一个函数,允许jQuery库与使用$
作为函数名的任何其他库兼容;如果其中一个脚本导致jQuery以兼容的方式运行,那么函数$
不是从jQuery中定义的,您只能使用jQuery()
访问任何jQuery功能
如果sites/all/modules/jquery\u update/replace/jquery.min.js
中的代码没有损坏,并且这不是由浏览器引起的问题,那么这是我能想到的唯一可能性
为了确保这不是另一个问题,我将使用jQuery库的非最小化版本。我在使用一些浏览器(主要是Internet Explorer 6,但问题可能出现在不同的浏览器中)时遇到了一些最小化的jQuery库问题。jQuery有一个函数,允许jQuery库与使用$
作为函数名的任何其他库兼容;如果其中一个脚本导致jQuery以兼容的方式运行,那么函数$
不是从jQuery中定义的,您只能使用jQuery()
访问任何jQuery功能
如果sites/all/modules/jquery\u update/replace/jquery.min.js
中的代码没有损坏,并且这不是由浏览器引起的问题,那么这是我能想到的唯一可能性
为了确保这不是另一个问题,我将使用jQuery库的非最小化版本。我在一些浏览器(主要是InternetExplorer6,但问题可能出现在不同的浏览器中)中使用最小化的jQuery库时遇到了一些问题。我怀疑您在加载jQuery或colorbox之前调用了该函数
尝试将调用更改为,并将其放在声明jquery调用的行下方
$(document).ready(function(){
$.colorbox({html:'<p>TEST TEST</p>'});
);
$(文档).ready(函数(){
$.colorbox({html:'TEST'});
);
这将在尝试调用函数之前等待脚本加载。我怀疑您是在加载jquery或colorbox之前调用函数的
尝试将调用更改为,并将其放在声明jquery调用的行下方
$(document).ready(function(){
$.colorbox({html:'<p>TEST TEST</p>'});
);
$(文档).ready(函数(){
$.colorbox({html:'TEST'});
);
这将等待脚本加载后再尝试调用函数。请按以下方式添加脚本:
color.css
jquery.min.js
请提及css类型
在页面的最开头添加doctype
我认为它肯定会起作用……请按以下方式添加脚本:
color.css
jquery.min.js
请提及css类型
在页面的最开头添加doctype
我想它肯定会起作用……当我点击第一行时,它会显示所有的jQuery源代码。当我点击第一行时,它会显示所有的jQuery源代码。谢谢你的回复。我会检查并让你知道我的发现。再次感谢!谢谢你的回复。我会检查并让你知道我的发现。Th又是anks!另一种选择是使用Drupal行为。另一种选择是使用Drupal行为。你已经开始工作了吗?你已经开始工作了吗?