0

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.

4

1 回答 1

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%.

于 2013-03-30T15:37:27.810 回答