我有一个包含3个脚本的页面:idTabs,lightbox(来自dreamweaver)和accordion(也来自dreamweaver)。我做了一些测试:灯箱不能用手风琴。他们每个人都很好,但手风琴崩溃联合起来,不起作用,灯箱工作。 这是一些代码:
<link href="style.css" rel="stylesheet" type="text/css" media="screen"> <script type="text/javascript" src="jquery.idTabs.min.js"></script> <script src="jquery-ui-1.7.2/js/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="jquery-ui-1.7.2/js/jquery-ui-1.7.2.min.js" type="text/javascript> </script> <script src="scripts/jquery.js" type="text/javascript"></script> <script src="scripts/lightbox.js" type="text/javascript"></script> <link href="jquery-ui-1.7.2/css/base/ui.core.css" rel="stylesheet" type="text/css" /> <link href="jquery-ui-1.7.2/css/base/ui.accordion.css" rel="stylesheet" type="text/css" /> <link href="jquery-ui-1.7.2/css/base/ui.theme.css" rel="stylesheet" type="text/css" /> <link href="jquery-ui-1.7.2/css/base/ui.images.css" rel="stylesheet" type="text/css" /> <script type="text/xml"> <!-- <oa:widgets> <oa:widget wid="2028523" binding="#jQueryUIAccordion" /> <oa:widget wid="2127022" binding="#gallery" /> </oa:widgets> --> </script> <link href="css/lightbox.css" rel="stylesheet" type="text/css" /> <link href="css/sample_lightbox_layout.css" rel="stylesheet" type="text/css" />
这是<head>
这是灯箱
<script type="text/javascript">
// BeginOAWidget_Instance_2127022: #gallery
$(function(){
$('#gallery a').lightBox({
imageLoading: '/images/lightbox/lightbox-ico-loading.gif', // (string) Path and the name of the loading icon
imageBtnPrev: '/images/lightbox/lightbox-btn-prev.gif', // (string) Path and the name of the prev button image
imageBtnNext: '/images/lightbox/lightbox-btn-next.gif', // (string) Path and the name of the next button image
imageBtnClose: '/images/lightbox/lightbox-btn-close.gif', // (string) Path and the name of the close btn
imageBlank: '/images/lightbox/lightbox-blank.gif', // (string) Path and the name of a blank image (one pixel)
fixedNavigation: false, // (boolean) Boolean that informs if the navigation (next and prev button) will be fixed or not in the interface.
containerResizeSpeed: 400, // Specify the resize duration of container image. These number are miliseconds. 400 is default.
overlayBgColor: "#999999", // (string) Background color to overlay; inform a hexadecimal value like: #RRGGBB. Where RR, GG, and BB are the hexadecimal values for the red, green, and blue values of the color.
overlayOpacity: .6, // (integer) Opacity value to overlay; inform: 0.X. Where X are number from 0 to 9
txtImage: 'Image', //Default text of image
txtOf: 'of'
});
});
// EndOAWidget_Instance_2127022
</script>
这是手风琴
<script type="text/javascript"> // BeginOAWidget_Instance_2028523: #jQueryUIAccordion $(function(){ // Accordion $("#jQueryUIAccordion").accordion({ header: "h3", > animated: "slide", event: "click", collapsible : "false" }); }); // EndOAWidget_Instance_2028523 </script> <!-- Accordion --> <div id="jQueryUIAccordion" class="ui-gray-icons "> <div> <h3><a href="#">First</a></h3> <div> Vivamus rutrum, sapien ac fermentum imperdiet, nisi libero mattis quam, eu mollis sem metus id ligula. </div> </div> <div> <h3><a href="#">Second</a></h3> <div>it, tristique egestas erat interdum id.</div> </div> <div> <h3><a href="#">Third</a></h3> <div>Nam dui erat, auctor a, dignissim quis.</div> </div>
我希望我没有失去你。我想强调一点,我没有修改脚本!它们与我在Dreamweaver中添加的相同。谢谢!
更新:我解决了这个问题。对于有这个问题的其他用户,只需从灯箱中删除jquery,手风琴的jquery将同时处理灯箱和手风琴!它可以关闭
稍后更新。我观察到只有歌剧加载了手风琴和灯箱。 firefox根本没有加载手风琴和灯箱。这是控制台错误: [12:56:53.907] $(“#jQueryUIAccordion”)。手风琴不是@ http://localhost/SITE/incercare3.php#:190的函数 [12:56:53.969] $(“#gallery a”)。lightBox不是函数@ http://localhost/SITE/incercare3.php#:275
chrome也没有加载2个脚本:这是chrome给我的错误:
未捕获TypeError:对象[object Object]没有方法'accordion' 未捕获的TypeError:对象[object Object]没有方法'lightBox'
意见?
答案 0 :(得分:1)
首先要加载jquery两次。这会引起冲突。
其次,我只看到你的标题中包含的lightbox和idTabs脚本,手风琴插件在哪里?
idTabs是在jquery之前加载的bean,让它在jquery之后加载。
看看你的jQuery版本,你正在使用同时需要jQuery 1.7和1.3的插件,你会遇到冲突。
无论如何,您可以使用jQuery.noConflict()同时使用这两个版本。
只是提示您更多地学习javascript:https://developer.mozilla.org/en/JavaScript/Guide