问题
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