画廊 + Colorbox 在 IE 中工作,在其他浏览器中不起作用
我以为我已经解决了这个问题,但不幸的是它在 FF 或 Chrome 中不起作用。我有一个图像列表,我希望将其显示为带有轮播的幻灯片在我的页面上。当用户单击较大的图像时,我希望它在灯箱中打开全尺寸图像。以下是在 IE 中运行的代码:
<script src="Scripts/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="Scripts/galleria.js" type="text/javascript"></script>
<script src="Scripts/galleria.classic.js" type="text/javascript"></script>
<script src="Scripts/jquery.colorbox-min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('a[rel=test]').colorbox();
$('#exteriorSlideShow_gallery').galleria({
max_scale_ratio: 1,
image_crop: false,
height: 210,
transition: 'fade',
extend: function() {
this.bind(Galleria.LOADFINISH, function(e) {
$(e.imageTarget).click(this.proxy(function(e) {
e.preventDefault();
$('a[rel=test]').eq(this.active).click();
}));
});
}
});
});
</script>
在上面,“this.active”表示轮播当前所在图像的索引。由于它与下面的链接显示的顺序相同,因此它对应于我想要单击的正确链接。
<div id="exteriorSlideShow_gallery">
<a href="/Images/ORIG1.gif" rel="test"><img src='/Images/THUMB1.gif' /></a>
<a href="/Images/ORIG2.gif" rel="test"><img src='/Images/THUMB2.gif' /></a>
<a href="/Images/ORIG3.gif" rel="test"><img src='/Images/THUMB3.gif' /></a>
</div>
有人知道为什么除了 IE 之外,这在其他任何地方都不起作用吗?
编辑 目前我已经采取了解决办法。如果浏览器是 IE,我将调用上面的代码,否则我使用 $.colorbox({ 'href': urloflargeimage })。除了 IE 之外,这不允许对图像进行分组,但至少我有一个灯箱。
I thought I had this worked out, but unfortunately it does not work in FF or Chrome. I have a list of images that I would like displayed as a slideshow with carousel on my page. When the user clicks on the larger image I would like it to open a full size image in a lightbox. Here is the code that works in IE:
<script src="Scripts/jquery-1.4.2.min.js" type="text/javascript"></script>
<script src="Scripts/galleria.js" type="text/javascript"></script>
<script src="Scripts/galleria.classic.js" type="text/javascript"></script>
<script src="Scripts/jquery.colorbox-min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('a[rel=test]').colorbox();
$('#exteriorSlideShow_gallery').galleria({
max_scale_ratio: 1,
image_crop: false,
height: 210,
transition: 'fade',
extend: function() {
this.bind(Galleria.LOADFINISH, function(e) {
$(e.imageTarget).click(this.proxy(function(e) {
e.preventDefault();
$('a[rel=test]').eq(this.active).click();
}));
});
}
});
});
</script>
In the above, "this.active" represents the index of the image in which the carousel is currently on. Since it is in the same order the links below are displayed in, it corresponds to the correct link I would like to have clicked.
<div id="exteriorSlideShow_gallery">
<a href="/Images/ORIG1.gif" rel="test"><img src='/Images/THUMB1.gif' /></a>
<a href="/Images/ORIG2.gif" rel="test"><img src='/Images/THUMB2.gif' /></a>
<a href="/Images/ORIG3.gif" rel="test"><img src='/Images/THUMB3.gif' /></a>
</div>
Anyone know why this wouldn't work in anything but IE?
EDIT
For the time being I have put in a work around. If the browser is IE I call the code as above else I use $.colorbox({ 'href': urloflargeimage }). This doesn't allow grouping of the images for anything but IE, but at least I have a lightbox up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Galleria 在获取必要的数据后会剥离大部分容器内容,但由于加载错误,它会将其隐藏在 IE 中。这就是为什么你的 hack 在 IE 中有效,但在其他地方无效。
我不确定 colorbox 是如何工作的,但看起来它不能采用正常的 URL 数组并将其分配为一组图像,然后手动调用每个框 onclick。但你也许可以做这样的事情(黑客):
Galleria strips most of your container content after grabbing necessary data, but it leaves it hidden in IE because of a loading bug. That is why your hack works in IE but not elsewhere.
I'm not sure how colorbox works, but it looks like it cannot take a normal array of URLs and assign it as a group of images and then call each box manually onclick. But you might be able to do something like this (hack):
我已经解决了这个问题。您必须将链接放在画廊容器外部,与图像分开,然后在单击图像时单击它们。像这样:
});
HTML 看起来像:
I have solved this. You have to put the links outside the galleria container, separate from the images, then click them when an image is clicked. Like so:
});
and the HTML looks like:
脚本标记缺少引号字符。你的实际来源是这样的吗?如果是这样,那可能会严重扰乱 Firefox。
具体
应该是
The script tag is missing a quote character. Is it like that in your actual source? If so, that could seriously upset Firefox.
Specifically
should be