Custom jQuery Banner Rotator only works in FireFox
I've wrote the following bit of jQuery for a banner rotator I have:
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/I开发者_StackOverflowtemImg_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);
}
}
However, this code only works in FireFox.
Internet Explorer 8 returns an 'Invalid Argument' error with Line 116 of the jQuery javascript file.
It's worth noting, this is only a code-snippet, and Featured_TopBanner
belongs to Auctions
. Also Auctions.Featured_TopBanner.Init();
is ran at Page Load.
Cheers
Try changing this (lines broken for clarity):
$(".auction_featured_top_img")
.css(
"background-image",
"url(/Auctions/ItemImg_TopBanner.ashx?itemid=" + featItem[0]
);
To this:
$(".auction_featured_top_img")
.css(
"background-image",
"url(/Auctions/ItemImg_TopBanner.ashx?itemid=" + featItem[0] + ")"
);
Note the missing closing parenthesis.
精彩评论