2010-11-23 67 views
0

我寫的jQuery的以下位一個橫幅肩,我有:自定義jQuery的橫幅旋轉器只適用於Firefox

Featured_TopBanner: { 
    Init: function() { 
     var featItems 
     $.ajax({ 
      url: '/Auctions/Auctions.asmx/Featured_TopBanner_Items' 
      , type: 'POST' 
      , contentType: 'application/json; charset=utf-8' 
      , dataType: 'json' 
      , success: function (data) { 
       Auctions.Featured_TopBanner.ChangeSlide(data.d); 
      } 
     }); 
    }, 
    ChangeSlide: function (featItems) { 

     var currentIndex = $(".auction_featured_top_currentindex").html(); 
     var newIndex = parseInt(currentIndex) + 1; 

     if (newIndex > (parseInt(featItems.length) - 1)) { 
      newIndex = 0; 
     }1 

     var featItem = featItems[newIndex]; 

     $(".auction_featured_top").fadeOut('slow', function() { 
      $(".auction_featured_top_img").css("background-image", "url(/Auctions/ItemImg_TopBanner.ashx?itemid=" + featItem[0]); 
      $(".auction_featured_top_link").attr("href", "/Auction/" + featItem[2] + ".aspx"); 
      $(this).fadeIn('slow'); 
     }); 

     $(".auction_featured_top_currentindex").html(newIndex); 

     setTimeout(function() { 
      Auctions.Featured_TopBanner.ChangeSlide(featItems); 
     }, 15000); 

    } 
} 

但是,此代碼只適用於Firefox。

Internet Explorer 8在jQuery javascript文件的第116行中返回'Invalid Argument'錯誤。

值得注意的是,這只是一段代碼片段,並且Featured_TopBanner屬於Auctions。在頁面加載時也運行Auctions.Featured_TopBanner.Init();

乾杯

回答

1

嘗試改變這(破線爲清楚起見):

$(".auction_featured_top_img") 
    .css(
     "background-image", 
     "url(/Auctions/ItemImg_TopBanner.ashx?itemid=" + featItem[0] 
    ); 

要這樣:

$(".auction_featured_top_img") 
    .css(
     "background-image", 
     "url(/Auctions/ItemImg_TopBanner.ashx?itemid=" + featItem[0] + ")" 
    ); 

注意缺少右括號。

+0

畢竟那個鬼怪!謝謝你的幫助 :) – Curt 2010-11-23 17:44:29