[英]IE 7 and 8 doesn't recognize jQuery's height and width?
I wrote a couple of functions using config
variable. 我使用config
变量编写了几个函数。 Here's how it looks like: 看起来是这样的:
scripts = function() {
var config = {
windowWidth: $(window).width(),
windowHeight: $(window).height()
}
function generatePages() {
$('section.main').each(function() {
$(this).css({
'width' : config.windowWidth,
'height': config.windowHeight
});
if($(this).children('.more').length) {
$(this).children('.more').css('line-height',config.windowHeight+'px')
}
});
}
return {
config:config,
generatePages:generatePages
}
}();
scripts.generatePages();
It works OK in all browsers, but IE 7-9 doesn't run generatePages
, it seems it doesn't "understand" $(window).width()
and height()
. 它在所有浏览器中都可以正常运行,但是IE 7-9不会运行generatePages
,似乎并不能“理解” $(window).width()
和height()
。 What can I do? 我能做什么?
As you commented on my question you're using jQuery 2.0.3, you can not use jQuery 2+ in older browsers: 当您对我的问题发表评论时,您正在使用jQuery 2.0.3,不能在较旧的浏览器中使用jQuery 2+:
As promised, this version leaves behind the older Internet Explorer 6, 7, and 8 browsers. 如承诺的那样,此版本保留了较旧的Internet Explorer 6、7和8浏览器。 In return it is smaller, faster, and can be used in JavaScript environments where the code needed for old-IE compatibility often causes problems of its own. 作为回报,它更小,更快,并且可以在JavaScript环境中使用,在该环境中,旧IE兼容性所需的代码通常会引起其自身的问题。 But don't worry, the jQuery team still supports the 1.x branch which does run on IE 6/7/8. 但是不用担心,jQuery团队仍然支持在IE 6/7/8上运行的1.x分支。 You can (and should) continue to use jQuery 1.9 (and the upcoming 1.10) on web sites that need to accommodate older browsers. 您可以(并且应该)继续在需要容纳较旧浏览器的网站上使用jQuery 1.9(以及即将发布的1.10)。
source: http://blog.jquery.com/2013/04/18/jquery-2-0-released/ 来源: http : //blog.jquery.com/2013/04/18/jquery-2-0-released/
Try it adding the px
measure: 尝试添加px
度量:
$(this).css({
'width': config.windowWidth + 'px',
'height': config.windowHeight + 'px'
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.