screen.width/height give wrong info about screen resolution

China☆狼群 提交于 2019-12-20 06:30:03

问题


My screen have resolution 1200 x 800 but this script give me 1429 x 893

<script>
if (screen) { 
var str = "Screen width:" + screen.width + "\n" + 
          "Screen height:" +  screen.height;
alert(str);
}
</script>

Why it doesn't work?

p.s. On other site this code screen.width + screen.height but when run it on localhost it give wrong info.


回答1:


From MDN :

Internet Explorer will take into account the zoom setting when reporting the screen width. It will only return the real width of the screen if the zoom is set to 100%.

So for some reason screen returns the wrong resolution when the browser is zoomed. Hitting ctrl-zero (zero on numpad) fixes that by zooming to 100%.



来源:https://stackoverflow.com/questions/15719908/screen-width-height-give-wrong-info-about-screen-resolution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!