admin管理员组文章数量:1318572
I have:
window.addEventListener('resize',doSomething,false);
function doSomething() {
var yres = document.body.offsetHeight;
var xres = document.body.offsetWidth;
alert(xres+'x'+yres);
}
This function shows my body resolution in google chrome my (1350x651), in firefox (1509x20) and in internet explorer (nothing). Why are the resolution from different browser different?
thanks.
I have:
window.addEventListener('resize',doSomething,false);
function doSomething() {
var yres = document.body.offsetHeight;
var xres = document.body.offsetWidth;
alert(xres+'x'+yres);
}
This function shows my body resolution in google chrome my (1350x651), in firefox (1509x20) and in internet explorer (nothing). Why are the resolution from different browser different?
thanks.
Share Improve this question asked Jan 1, 2012 at 11:27 KruegerKrueger 1,2283 gold badges13 silver badges27 bronze badges2 Answers
Reset to default 5With jQuery it's simple, do something like:
$(window).width();
$(document).width();
$(window).height();
$(document).height();
Without js this should suffice:
screen.height;
screen.width;
In your case im guessing you would use window since that's where you added the listener. Also, http://www.javascripter/faq/browserw.htm could help with some more foolproof code since offsetWidth and Height seems to be some IE thing.
You should use window.innerWidth
and window.innerHeight
本文标签: javascriptBrowser39s screen resolutionStack Overflow
版权声明:本文标题:javascript - Browser's screen resolution? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742047630a2417882.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论