我已经开发了下面的代码,每x秒只交换一个图像。所有工作正常,并返回在Chrome中没有错误。但是,在IE(最新回到IE8)中,它什么都不做,不返回任何错误,只停留在第一张图片上。JavaScript在IE,.data中不起作用? setInterval的?
有什么建议吗?我记得在某个地方阅读setInterval可能导致IE中的问题。
考虑:
$(function() {
var fElement = $('.fadein');
fElement.find('img:gt(0)').hide();
setInterval(function() {
if (!fElement.data('paused')) {
fElement.find(':first-child')
.stop(true, true) // fixes le tabbed/hidden animation queue
.fadeOut()
.next('img')
.fadeIn()
.end()
.appendTo('.fadein');
} else {
console.log('waiting...');
}
}, 2000);
$('map').hover(
function() {
console.log('pausing');
fElement.data('paused', 1);
},
function() {
console.log('unpausing');
fElement.data('paused', 0);
}
);
});
if (!console && !console.log) {
console = {};
console.log = function() {};
}
和CSS:
.fadein {
display: block;
height: 49px;
width: 287px;
float: left;
}
.fadein img {
position:absolute;
}
.stripContainer {
display:block;
height: 49px;
}
和HTML:
<div class="fadein">
<img src="img1.jpg" border="0" width="287" height="49" alt="" style="" id="level2Menu"/>
<img src="img2.jpg" border="0" width="287" height="49" alt="" style="" id="level2Menu"/>
</div>
<div class="stripContainer">
<img src="img3.jpg" usemap="#secondM" border="0" width="385" height="49" alt="" style="float:left;" id="level2Menu"/>
<img src="img4.jpg" usemap="#secondM" border="0" width="288" height="49" alt="" style="float:right;" id="level2Menu"/>
</div>
编辑:这拨弄显示它的工作,因为它应该在Chrome:http://jsfiddle.net/8f5uU/
如果您想到问题的真实标题,您可能会获得更多帮助。 –
jQuery 2.X版本不支持IE <9。 – Teemu
@CoreyOgburn我不知道该怎么称呼这个问题,我试过console.log'ing,我无法找到问题所在。这实际上是一个IE/JS问题。 – Myles