Javascript jquery脚本可以在chrome和firefox中使用,但不能在ie中使用(交叉淡入淡出图片)
有人能看一下这个页面并找出为什么它在Internet Explorer中看起来不正确吗?它在Chrome和Firefox中看起来不错,但在IE中,照片的布局变得混乱,特别是页面右侧的两张照片 我假设它与这个脚本有关,但我不是javascript或jquery专家,也不是新手Javascript jquery脚本可以在chrome和firefox中使用,但不能在ie中使用(交叉淡入淡出图片),javascript,jquery,image-gallery,Javascript,Jquery,Image Gallery,有人能看一下这个页面并找出为什么它在Internet Explorer中看起来不正确吗?它在Chrome和Firefox中看起来不错,但在IE中,照片的布局变得混乱,特别是页面右侧的两张照片 我假设它与这个脚本有关,但我不是javascript或jquery专家,也不是新手 // wrap as a jQuery plugin and pass jQuery in to our anoymous function (function ($) { $.fn.cross = functio
// wrap as a jQuery plugin and pass jQuery in to our anoymous function
(function ($) {
$.fn.cross = function (options) {
return this.each(function (i) {
// cache the copy of jQuery(this) - the start image
var $$ = $(this);
// get the target from the backgroundImage + regexp
var target = $$.css('backgroundImage').replace(/^url|[\(\)'"]/g, '');
// nice long chain: wrap img element in span
$$.wrap('<span style="position: relative;"></span>')
// change selector to parent - i.e. newly created span
.parent()
// prepend a new image inside the span
.prepend('<img>')
// change the selector to the newly created image
.find(':first-child')
// set the image to the target
.attr('src', target);
// the CSS styling of the start image needs to be handled
// differently for different browsers
if ($.browser.msie || $.browser.mozilla) {
$$.css({
'position' : 'absolute',
'left' : 0,
'background' : '',
'top' : this.offsetTop
});
} else if ($.browser.opera && $.browser.version < 9.5) {
// Browser sniffing is bad - however opera < 9.5 has a render bug
// so this is required to get around it we can't apply the 'top' : 0
// separately because Mozilla strips the style set originally somehow...
$$.css({
'position' : 'absolute',
'left' : 0,
'background' : '',
'top' : "0"
});
} else { // Safari
$$.css({
'position' : 'absolute',
'left' : 0,
'background' : ''
});
}
// similar effect as single image technique, except using .animate
// which will handle the fading up from the right opacity for us
$$.hover(function () {
$$.stop().animate({
opacity: 0
}, 450);
}, function () {
$$.stop().animate({
opacity: 1
}, 1000);
});
});
};
})(jQuery);
// note that this uses the .bind('load') on the window object, rather than $(document).ready()
// because .ready() fires before the images have loaded, but we need to fire *after* because
// our code relies on the dimensions of the images already in place.
$(window).bind('load', function () {
$('img.fade').cross();
});
//包装为jQuery插件,并将jQuery传递给我们的anoymous函数
(函数($){
$.fn.cross=函数(选项){
返回这个。每个(函数(i){
//缓存jQuery的副本(此)-开始映像
变量$$=$(此);
//从backgroundImage+regexp获取目标
var target=$$.css('backgroundImage')。替换(/^url |[\(\)'“]/g');
//漂亮的长链:在跨度中包裹img元素
$$.wrap(“”)
//将选择器更改为父级-即新创建的范围
.parent()
//在跨度内预先添加新图像
.prepend(“必须是IE中定位的常见错误。我建议阅读的第一个答案,看看这是否有助于解决您的问题。尝试将代码更改为下面,它应该可以修复您右侧的照片。=)
如果你具体描述IE中出现的问题,你可能会更快地得到答案。
// the CSS styling of the start image needs to be handled
// differently for different browsers
if ($.browser.msie || $.browser.mozilla) {
$$.css({
'position' : 'absolute',
'left' : 0,
'background' : ''
});