jQuery jcarousel 在 Chrome 中无法正常工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1997993/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jcarousel doesn't work properly in Chrome
提问by dexter
in my code i am creating a ul li for the jcarousel ie its a list of data(ex. list of photo)
在我的代码中,我正在为 jcarousel 创建一个 ul li,即它的数据列表(例如照片列表)
when the photo count is more than say 4 , the jcarousel enables horizontal scrolling so as to see next 4 photos .
当照片数量超过 4 张时,jcarousel 启用水平滚动以便查看接下来的 4 张照片。
PROBLEM: is when i run the code in chrome the horizontal scrolls remain disabled even if number of photos is more than 4, in other browsers it works perfectly..
问题:当我在 chrome 中运行代码时,即使照片数量超过 4,水平滚动仍保持禁用状态,在其他浏览器中它可以完美运行..
heres the code which imports jquery file:
这是导入jquery文件的代码:
function SetCarousel() {
$.getScript('<%=Html.LibUrl("jplugins/jquery.jcarousel.pack.js")%>',
function(result)
{
jQuery('#CarouselUL').jcarousel({
visible: 4
});
});
}
i have tried refering .js file @ top of page(aspx) didn't work ..even made it worse
我试过引用 .js 文件 @top of page(aspx) 没有用 .. 甚至让它变得更糟
pls help
请帮忙
回答by jsims281
I fixed this on a site I was working on by commenting out code which specifies Safari; for some reason the fixes they put in appear to have become obsolete. I'm using jQuery 1.3.2.
我通过注释掉指定 Safari 的代码在我正在处理的站点上修复了这个问题;出于某种原因,他们所做的修复似乎已经过时了。我正在使用 jQuery 1.3.2。
Here's the code I stripped out:
这是我剥离的代码:
jquery.carousel.js:around line 184
jquery.carousel.js:大约第 184 行
/*if ($.browser.safari) {
this.buttons(false, false);
$(window).bind('load', function() { self.setup(); });
} else */
this.setup();
jquery.carousel.js:around line 858
jquery.carousel.js:在第 858 行附近
/*if (p == 'marginRight' && $.browser.safari) {
var old = {'display': 'block', 'float': 'none', 'width': 'auto'}, oWidth, oWidth2;
$.swap(el, old, function() { oWidth = el.offsetWidth; });
old['marginRight'] = 0;
$.swap(el, old, function() { oWidth2 = el.offsetWidth; });
return oWidth2 - oWidth;
}*/
Hopefully this fix will help you and others who come across the problem!
希望此修复程序可以帮助您和其他遇到问题的人!
回答by Jp Bassinello
I tried number 1 solution and it worked. Nice man, thank you very much. I just commented the lines:
我尝试了 1 号解决方案,它奏效了。好人,非常感谢。我只是评论了以下几行:
/*if ($.browser.safari) {
this.buttons(false, false);
$(window).bind('load', function() { self.setup(); });
} else */
this.setup();
回答by mujaffar
This is awesome my problem is resolved thanks jsims281
这太棒了,我的问题解决了,感谢 jsims281
In my case i have used
就我而言,我使用过
jquery.jcarousel.min
jquery.jcarousel.min
and the code commented is line no 134 to 139
注释的代码是第 134 到 139 行
/*if(!q&& i.browser.safari){
this.buttons(false,false);
i(window).bind("load.jcarousel",function(){
g.setup()
})
}else */ this.setup()
};
and line no 470 to 484
和第 470 至 484 行
/*if(c=="marginRight"&&i.browser.safari){
var d={
display:"block",
"float":"none",
width:"auto"
},e,f;
i.swap(b,d, function(){
e=b.offsetWidth
});
d.marginRight=0;
i.swap(b,d,function(){
f=b.offsetWidth
});
return f-e
}*/
回答by VRC
In version 0.2.9 this worked for me.
I took the minified version and threw it through the http://jsbeautifier.organd changed the following on line 95
在 0.2.9 版本中,这对我有用。
我把缩小的版本扔到http://jsbeautifier.org并在第 95 行更改了以下内容
}, null !== this.options.initCallback && this.options.initCallback(this, "init"), !c && d.isSafari() ? (this.buttons(!1, !1), a(window).bind("load.jcarousel", function ()
{
l.setup()
})) : this.setup()
to
到
}, null !== this.options.initCallback && this.options.initCallback(this, "init"), !c /*&& d.isSafari() ? (this.buttons(!1, !1), a(window).bind("load.jcarousel", function ()
{
l.setup()
})) :*/ this.setup()
回答by Dreaded semicolon
It seems only one condition left in version 0.28 and it causes delay in completing the setup
看来 0.28 版本只剩下一个条件了,这会导致完成设置的延迟
Based on Jsims281 (thanks Jsims) , I searched the minimized version of jCarousel v0.28 and found that line as following:
基于 Jsims281(感谢 Jsims),我搜索了 jCarousel v0.28 的最小化版本,发现该行如下:
!m&&g.browser.safari?(this.buttons(!1,!1),g(window).bind("load.jcarousel",function(){e.setup()})):
should comment the above to be:
应将上述内容评论为:
/*!m&&g.browser.safari?(this.buttons(!1,!1),g(window).bind("load.jcarousel",function(){e.setup()})):*/
回答by Dreaded semicolon
very nice... jquery.carousel.js:around line 184
非常好... jquery.carousel.js:在第 184 行附近
/*if ($.browser.safari) { this.buttons(false, false); $(window).bind('load', function() { self.setup(); }); } else */ this.setup();
/*if ($.browser.safari) { this.buttons(false, false); $(window).bind('load', function() { self.setup(); }); } else */ this.setup();
jquery.carousel.js:around line 858
jquery.carousel.js:围绕第 858 行
/*if (p == 'marginRight' && $.browser.safari) {
var old = {'display': 'block', 'float': 'none', 'width': 'auto'}, oWidth, oWidth2;
$.swap(el, old, function() { oWidth = el.offsetWidth; });
old['marginRight'] = 0;
$.swap(el, old, function() { oWidth2 = el.offsetWidth; });
return oWidth2 - oWidth;
}*/
This is working very well.... Thanks....
这工作得很好......谢谢......
回答by jitter
I suppose you mean this jCarousel?
我想你的意思是这个jCarousel?
If yes, what jQuery version are you using?
如果是,您使用的是什么 jQuery 版本?
Because this plugin hasn't had any updates for a long time now. Current version is 0.2.3 from April 07, 2008 and the changelog for this version says
因为这个插件已经很久没有更新了。当前版本是 0.2.3,自 2008 年 4 月 7 日起,此版本的变更日志显示
Version 0.2.3 - 2008-04-07 Updated
- jQuery to version 1.2.3. Fixed
- (hopefully) issues with Safari
版本 0.2.3 - 2008-04-07 更新
- jQuery 到版本 1.2.3。已修复
-(希望)Safari 的问题
I recall this plugin having some problems with newer jQuery versions starting with 1.2.6 (today we are at 1.3.2 already).
我记得这个插件在从 1.2.6 开始的较新 jQuery 版本上有一些问题(今天我们已经在 1.3.2 了)。
Also you must be aware that the current version of jCarousel appeared before the first release of Google Chrome (version 0.2 came out on the September 08, 2008).
此外,您必须知道当前版本的 jCarousel 出现在 Google Chrome 的第一个版本之前(0.2 版于 2008 年 9 月 8 日发布)。