admin管理员组文章数量:1278978
Does anybody here know what the Javascript call is to get the width/height of the entire browser window (including nav, menu, etc?)
I know there is outerWidth
, outerHeight
in FF, Safari and other browsers.
Does anybody here know what the Javascript call is to get the width/height of the entire browser window (including nav, menu, etc?)
I know there is outerWidth
, outerHeight
in FF, Safari and other browsers.
5 Answers
Reset to default 3This also could be helpful, depending on what exactly you're trying to acplish:
window.moveTo(0,0); window.resizeTo(screen.width,screen.height); var navButtonsEtcHeight = screen.height - window.innerHeight; var navButtonsEtcWidth = screen.width - window.innerWidth;
Note: For browser-independent solution to "window.innerHeight" support, see this link
Then you have the answer you're looking for -- mind you, with the downside of the non-fullscreen user seeing their window bounce around the screen first.
It's a variation of DreadPirateShawn's answer. Tested on IE7 and Chrome8. Originally appearing on Experts Exchange.
function getWindowSize() {
var wW, wH;
if (window.outerWidth) {
wW = window.outerWidth;
wH = window.outerHeight;
} else {
var cW = document.body.offsetWidth;
var cH = document.body.offsetHeight;
window.resizeTo(500,500);
var barsW = 500 - document.body.offsetWidth;
var barsH = 500 - document.body.offsetHeight;
wW = barsW + cW;
wH = barsH + cH;
window.resizeTo(wW,wH);
}
return { width: wW, height: wH };
}
I don't think it is possible.
It might be worth reviewing Chapter 14 of O'Reilly's: JavaScript - The Definitive Guide, particularly section 14.3.1.
I believe this is what you want
document.body.offsetWidth
document.body.offsetHeight
I think you can use
width: window.outerWidth
height: window.outerHeight
you can use jquery so it wont be undefined in ie. You might try and figure out there screen size first and then using the dimensions of the browser figure out the precise size.
doc: http://docs.jquery./Plugins/dimensions/outerHeight
本文标签: javascriptGetting the widthheight of the entire browser in IEStack Overflow
版权声明:本文标题:javascript - Getting the widthheight of the entire browser in IE? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741279403a2369918.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论