2017-10-17 84 views
0

我有以下代码来自动更改背景图像。Internet Explorer上的光标焦点问题

function changeBackground() { 
    currentBackground++; 
    if(currentBackground > 3) currentBackground = 0; 

    $('body').fadeOut(0, function() { 
     $('body').css({ 
      'background-image' : "url('" + backgrounds[currentBackground] + "')" 
     }); 
     $('body').fadeIn(0); 
    }); 


    setTimeout(changeBackground, 3000); 

我在前面有一个简单的表单。在Internet Explorer中,这种形式的重点似乎每次去的影像学改变,但效果很好Chrome和Firefox

回答

1

jQuery的fadeOut动画不透明度降低到0 ,然后设置display: none

我认为当它在一个display: none容器中时,Internet Explorer将焦点从表单中移开。

你可以尝试使用animate()代替:

$('body').animate({ opacity: 0}, 0, function() { 
    $('body').css({ 
     'background-image' : "url('" + backgrounds[currentBackground] + "')" 
    }); 
    $('body').animate({ opacity: 1 }, 0); 
}); 

一个问题:您正在使用即时转换(传球0的持续时间),那么,为什么你叫淡入/淡出? (它看起来像css()电话本身就足够了)