我为我的横幅旋转器写了下面的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();
在页面加载时运行。
干杯
答案 0 :(得分: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] + ")"
);
请注意缺少右括号。