我写的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();是RAN在页面加载。

干杯

有帮助吗?

解决方案

尝试改变该(折断线为清楚起见):

$(".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归因
不隶属于 StackOverflow
scroll top