[英]Why JS/Jquery does not seem to work in IE7
For some reason my Jquery script won't work on IE7. 由于某种原因,我的Jquery脚本无法在IE7上运行。 It does however work in all other browsers. 但是,它可以在所有其他浏览器中使用。 I have read somewhere that IE7 is very picky on commas and such, but I can't figure out what I have done wrong here. 我在某处读到IE7对逗号非常挑剔,但是我无法弄清楚我在这里做错了什么。 Any clues? 有什么线索吗?
$(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);
});
});
As you suspected, the problem is that you have some trailing commas here that mess up in old IE. 正如您所怀疑的那样,问题在于您在这里有一些逗号在旧的IE中弄乱了。 The offending lines are 令人反感的是
marginLeft: '0',
and 和
right: '0',
... twice each. ...各两次。
Here's a site I found via a quick web search that finds trailing commas in JavaScript code. 这是我通过快速网络搜索找到的站点,该站点以JavaScript代码查找结尾的逗号。 It seems to work. 它似乎有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.