2015-03-02 196 views
1

我試圖在按鈕單擊上顯示動畫GIF,但它在IE(8,9)中凍結,適用於IE11,FF和Chrome。動畫GIF在IE中停止,但在FF和Chrome中工作

是否有任何解決方法。

這裏是html代碼;

<!DOCTYPE html> 

     <html xmlns="http://www.w3.org/1999/xhtml"> 
     <head runat="server"> 


     <link rel="stylesheet" type="text/css" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/start/jquery-ui.css" /> 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
      <title></title> 

      <style type="text/css"> 

      .cssbox-progress { 
      background-image: url('images/3.gif'); 
      background-repeat: no-repeat; 
      } 

      .loading 
      { 
       width: 50px; 
       height: 10px; 
       display: none; 
       background-color: White;     
      } 

     </style> 

     <script > 
      function ShowProgress() { 
       setTimeout(function() { 

        var loading = $(".loading"); 
        loading.show(); 
       }, 200); 
      } 
      function test() { 
       ShowProgress(); 
      } 

     </script> 

     </head> 
     <body> 
      <form id="form1" runat="server"> 
       <div class="loading" align="center" style="width: 50px; height: 10px; "> 

       <div class="cssbox-progress" style="width: 50px; height: 10px;"></div> 

       </div> 

     <asp:Button ID="btn" runat="server" Text="Login" onclientclick ="test()" /> 


      </form> 
     </body> 
     </html> 

動畫GIF

enter image description here

+2

我強烈懷疑IE 8和9支持動畫GIF作爲div背景圖片。使用標記代替(爲什麼你不?)此外,你的代碼顯示'$(「。loading」)','$(「。loading」)'只是一個空的div。我認爲它確實是它應該做的:) – 2015-03-02 10:08:15

+0

我不確定如果我可以使用圖像標記作爲GIF圖像需要在CSS中設置。 – user1263981 2015-03-02 10:11:44

+0

是的,你可以使用圖像標籤。這是Jeremy所說的問題,IE8,9上的背景圖像不支持動畫。 – Aristos 2015-03-02 10:15:07

回答

0

在迴應的意見,這裏是情景: 1 - 你需要顯示 「加載」 gif動畫。 2- gif在IE 8/9中沒有動畫。 3-您需要更改CSS中的源代碼,因爲您使用的是主題。

,答案是

<style> 
.cssbox-progress { 
    content: url('http://i.stack.imgur.com/dS784.gif'); 
} 
</style> 

<img class="cssbox-progress" /> 

我沒有測試它在IE 8/9,雖然,我使用插件來測試它如何模樣,但你應該測試它來確保。

相關問題