簡體   English   中英

自定義jQuery Banner Rotator僅在FireFox中有效

[英]Custom jQuery Banner Rotator only works in FireFox

我為具有的橫幅旋轉器編寫了以下jQuery:

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行返回“無效參數”錯誤。

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

干杯

嘗試更改此設置(為了清晰起見,將行斷開):

$(".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] + ")"
   );

請注意缺少右括號。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM