this page上有两个附加了Javascript的元素。左侧的捐赠框和中间的图像滑块。图像滑块在延时时滚动,而捐赠框在悬停时更改其左侧位置,然后在释放悬停时返回。这适用于FF和Chrome。
在IE中,两个元素之间似乎存在某种冲突。一旦我运行hover命令,滑块就会停止工作。悬停也只能运行一次,并且需要页面刷新才能再次运行。
有什么方法可以解决这个问题吗?
这是图像滑块的代码:
<script type="text/javascript">
$(document).ready(function() {
//Set Default State of each portfolio piece
$(".paging").show();
$(".paging a:first").addClass("active");
//Get size of images, how many there are, then determin the size of the image reel.
var imageWidth = $(".window").width();
var imageSum = $(".image_reel img").size();
var imageReelWidth = imageWidth * imageSum;
//Adjust the image reel to its new size
$(".image_reel").css({'width' : imageReelWidth});
//Paging + Slider Function
rotate = function(){
var triggerID = $active.attr("rel") - 1; //Get number of times to slide
var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide
$(".paging a").removeClass('active'); //Remove all active class
$active.addClass('active'); //Add active class (the $active is declared in the rotateSwitch function)
//Slider Animation
$(".image_reel").animate({
left: -image_reelPosition}, {
duration: 2000,
easing: 'easeInOutQuad'
})
}
//Rotation + Timing Event
rotateSwitch = function(){
play = setInterval(function(){ //Set timer - this will repeat itself every 3 seconds
$active = $('.paging a.active').next();
if ( $active.length === 0) { //If paging reaches the end...
$active = $('.paging a:first'); //go back to first
}
rotate(); //Trigger the paging and slider function
}, 6000); //Timer speed in milliseconds (3 seconds)
};
rotateSwitch(); //Run function on launch
//On Hover
$(".image_reel a").hover(function() {
clearInterval(play); //Stop the rotation
}, function() {
rotateSwitch(); //Resume rotation
});
//On Click
$(".paging a").click(function() {
$active = $(this); //Activate the clicked paging
//Reset Timer
clearInterval(play); //Stop the rotation
rotate(); //Trigger rotation immediately
rotateSwitch(); // Resume rotation
return false; //Prevent browser jump to link anchor
});
});
</script>
这是捐赠箱:
$(document).ready(function() {
$('#donatebox').hover(function() {
$('#donatebox').animate({
'left': parseInt($(this).css('left'),10) == 295 ?
$(this).animate({'left': '0px'}, 1000,'easeOutQuad') :
295
});
});
});
它超出了我的范围,所以我用另一种不需要解析的方式(我真的不明白......)来解决这个问题。
$(document).ready(function() {
$('#donatebox').mouseenter(
function() {
$('#donatebox').animate({"marginLeft": -5}, 1000, "easeOutBounce");
});
});
$(document).ready(function() {
$("#donatebox").mouseleave (
function() {
$(this).animate({"marginLeft": -5}, 20).animate({"marginLeft": -305}, 700, "easeOutQuad");
});
});
答案 0 :(得分:1)
当div
已经放回其插槽时,某些内容会导致jQuery“缓动”插件出现Javascript错误。这就是为什么在使用Donate框一次后没有脚本运行的原因。
如果您在IE中使用开发者工具,您会发现错误被捕获。然后(虽然动画是分离的,所以你不能只是上升到callstack),可以推断出问题出在你从custom.js发起的动画中:
$('#donatebox').animate({
'left': parseInt($(this).css('left'),10) == 295 ?
$(this).animate({'left': '0px'}, 1000,'easeOutQuad') :
295
});
^看起来不合适。
您还有重复的HTML节点ID overimage
。 ID 唯一;也许你打算使用课程?
答案 1 :(得分:1)
也许对你有所帮助。
答案 2 :(得分:0)
这是由{JACery-latest.js的第8538行Invalid Argument
例外引起的