2017-10-17 99 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()電話本身就足夠了)