由于某些原因,我的Jquery脚本无法在IE7上运行。但它确实适用于所有其他浏览器。我已经读过IE7在逗号等方面非常挑剔,但我无法弄清楚我在这里做错了什么。有线索吗?
$(document).ready(function() {
var isiPad = navigator.userAgent.toLowerCase().indexOf("ipad");
var paddingLeft = ($(window).width() - 820) / 2;
var paddingRight = ($(window).width() - 820) / 2;
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) )
{
$(window).resize(function()
{
paddingLeft = ($(window).width() - 820) / 2;
$('.block_bouw').css('padding-left', paddingLeft);
paddingRight = ($(window).width() - 820) / 2;
$('.block_industrie').css('padding-right', paddingRight);
});
$('.block_bouw').css('padding-left', paddingLeft);
$('.block_bouw').delay(0).animate({
marginLeft: '0',
}, 0, function() {
});
$('.block_bouw').click(function(){
window.location = 'bouw';
});
$('.block_industrie').css('padding-right', paddingRight);
$('.block_industrie').delay(0).animate({
right: '0',
}, 0, function(){
});
$('.block_industrie').click(function(){
window.location = 'industrie';
});
}
else {
$(window).resize(function()
{
paddingLeft = ($(window).width() - 820) / 2;
$('.block_bouw').css('padding-left', paddingLeft);
paddingRight = ($(window).width() - 820) / 2;
$('.block_industrie').css('padding-right', paddingRight);
});
$('.block_bouw').css('padding-left', paddingLeft);
$('.block_bouw').delay(500).animate({
marginLeft: '0',
}, 2000, function() {
});
$('.block_bouw').click(function(){
window.location = 'bouw';
});
$('.block_industrie').css('padding-right', paddingRight);
$('.block_industrie').delay(500).animate({
right: '0',
}, 2000, function(){
});
$('.block_industrie').click(function(){
window.location = 'industrie';
});
}
$(".product.module .item").css("margin-right","27px");
$(".product.module .item:nth-child(3n)").css("margin-right", "0px");
$(".project.module .item").css("margin-left","26px");
$(".project.module .item:nth-child(3n)").css("margin-left", "0px");
$('.popout', this).hide();
$('.pin').hover(function(){
//var h = $('.popout', this).outerHeight() * -1;
var id = (this.id);
$('.popout').css("margin-top", ($('.popout',this).outerHeight()*-1)+14 );
$('.popout', this).show(100);
$('.option' + "#" + id).addClass('hover');
},function(){
$('.popout', this).hide(100);
$('.option').removeClass('hover');
});
$('.option').hover(function(){
var idoption = (this.id);
$('.popout').css("margin-top", ($('.popout' + "#" + idoption).outerHeight()*-1)+14 );
$('.popout' + "#" + idoption).stop().show(100);
},function(){
$('.popout').hide(100);
});
});
答案 0 :(得分:3)
正如您所怀疑的那样,问题是您在这里有一些尾随的逗号,它们在旧的IE中搞乱了。违规行是
marginLeft: '0',
和
right: '0',
......每次两次。
这是我通过快速网络搜索找到的网站,可以在JavaScript代码中找到尾随逗号。它似乎有效。