最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - window.innerWidth can't work on IE7. How to fix via JS and jQuery? - Stack Overflow

programmeradmin3浏览0评论

I wanna get the width of browser window. It should contain the width of scroll bar if exists.

How to fix this issue via JS?

How to fix this issue via jQuery?

Thank you!

I wanna get the width of browser window. It should contain the width of scroll bar if exists.

How to fix this issue via JS?

How to fix this issue via jQuery?

Thank you!

Share Improve this question edited Mar 2, 2013 at 0:04 Josh Unger 7,2137 gold badges37 silver badges55 bronze badges asked Mar 5, 2012 at 8:30 weilouweilou 4,62811 gold badges45 silver badges56 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 6

There are many examples of this scattered around the web. It's a mon problem. Here's what I found in a quick search

var winW = 630, winH = 460;
if (document.body && document.body.offsetWidth) {
 winW = document.body.offsetWidth;
 winH = document.body.offsetHeight;
}
if (document.patMode=='CSS1Compat' &&
    document.documentElement &&
    document.documentElement.offsetWidth ) {
 winW = document.documentElement.offsetWidth;
 winH = document.documentElement.offsetHeight;
}
if (window.innerWidth && window.innerHeight) {
 winW = window.innerWidth;
 winH = window.innerHeight;
}

http://www.javascripter/faq/browserw.htm

this would fix using a jquery $(window).innerWidth();

发布评论

评论列表(0)

  1. 暂无评论