灯箱手风琴冲突
我有一个包含 3 个脚本的页面:idTabs、lightbox(来自 Dreamweaver)和 Accordion(也来自 Dreamweaver)。我做了一些测试:灯箱不适用于手风琴。他们每个人单独工作正常,但组合手风琴崩溃,不起作用,灯箱工作。 这是一些代码:
<脚本类型=“text/javascript”src=“jquery.idTabs.min.js”> <脚本 src="jquery-ui-1.7.2/js/jquery-1.3.2.min.js" type="text/javascript"> <脚本 src="jquery-ui-1.7.2/js/jquery-ui-1.7.2.min.js" type="text/javascript> <脚本 src="scripts/jquery.js" type="text/javascript"> <脚本 src="scripts/lightbox.js" type="text/javascript"> > > > > <脚本类型=“text/xml”> >
这是在
这是灯箱
<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>
这是手风琴
<脚本类型=“text/javascript”> // BeginOAWidget_Instance_2028523: #jQueryUIAccordion $(函数(){ // 手风琴 $("#jQueryUIAccordion").accordion({ header: "h3", >动画:“幻灯片”, 事件:“点击”, 可折叠:“假” }); }); // EndOAWidget_Instance_2028523
我希望我没有失去你。我想强调的是,我没有对脚本进行任何修改!它们与我从 Dreamweaver 添加的相同。谢谢 !
更新:我解决了问题。对于遇到此问题的其他用户,只需从 lightbox 中删除 jquery,accordion 中的 jquery 将同时处理 lightbox 和 Accordion !它可以在稍后更新时关闭
。我观察到只有歌剧可以加载手风琴和灯箱。 Firefox 根本不加载手风琴和灯箱。这是控制台错误: [12:56:53.907] $("#jQueryUIAccordion").accordion 不是一个函数@ http:// /localhost/SITE/incercare3.php#:190 [12:56:53.969] $("#gallery a").lightBox 不是一个函数@ http: //localhost/SITE/incercare3.php#:275
chrome 也不会加载 2 个脚本:这是 chrome 给我的错误:
Uncaught TypeError: Object [object Object] has没有方法“手风琴” 未捕获的类型错误:对象 [object Object] 没有方法“lightBox”
意见?
i have a page with 3 scripts: idTabs, lightbox ( from dreamweaver) and accordion(also from dreamweaver) . I made some tests: lightbox doesnt work with accordion. each of them alone works fine, but combined accordion crashes, doesn't work and lightbox works.
here is some code :
<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" />
this is in <head>
this is lightbox
<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>
this is the accordion
<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>
I hope I haven't lost you. I want to underline that I made no modifications to the scripts ! they are the same as I added from dreamweaver. THANK YOu !
UPDATE: i solved the problem. For other users who have this problem, just DELETE the jquery from lightbox, the jquery from accordion will take care of both lightbox and accordion ! it can be closed
LATER UPDATE. i observed that only opera loads OK accordion and lightbox. firefox doesnt load accordion and lightbox at all. this is the console errors :
[12:56:53.907] $("#jQueryUIAccordion").accordion is not a function @ http://localhost/SITE/incercare3.php#:190
[12:56:53.969] $("#gallery a").lightBox is not a function @ http://localhost/SITE/incercare3.php#:275
chrome also doesnt load the 2 scripts: this are the errors chrome gives me :
Uncaught TypeError: Object [object Object] has no method 'accordion'
Uncaught TypeError: Object [object Object] has no method 'lightBox'
Opinions ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先你要加载 jquery 两次。这会引起冲突。
其次,我只看到标题中包含 lightbox 和 idTabs 脚本,手风琴插件在哪里?
idTabs是在jquery之前加载的bean,使其在jquery之后加载。
看一下你的jQuery版本,你使用的插件同时需要jQuery 1.7和1.3,你会发生冲突。
无论如何,您可以使用 jQuery.noConflict() 同时使用这两个版本。
只是给你更多地学习 javascript 的一个提示:https://developer.mozilla.org/en /JavaScript/指南
First thing you are loading jquery twice times. This will cause conflicts.
Second, I just see lightbox and idTabs scripts included in your header, where is the accordion plugin?
idTabs is bean loaded before jquery, make it loads after jquery.
Take a look in the version of your jQuery, you are using plugins that require jQuery 1.7 and 1.3 at same time, you will have conflict.
Anyway you can use jQuery.noConflict() to use the both versions at same time.
Just a tip for you to studies javascript a bit more: https://developer.mozilla.org/en/JavaScript/Guide