搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

Mozilla returns wrong screen size

  • 3 个回答
  • 1 人有此问题
  • 1 次查看
  • 最后回复者为 AleCaste

more options

The screen size of my laptop is 1366 x 768 IE9, Chrome and Opera are all returning these values when using screen.width and screen.height

On Chrome, even when you zoom in, the values being returned are still 1366 x 768 as they should be since the screen size of my laptop is what it is and does not "change" when you zoom in/out.

Firefox 30.0 is returning 1093 x 614 !!!! WHY???? I made sure the zoom was reset (CTRL+0) and still the values are those... wrong! I played around with the DPI settings on Firefox (layout.css.devPixelsPerPx) to no avail.

I must say that I am using Windows 7 with a higher font-size (125%). Could this be the problem???? If so, I do not understand why; again, my screen size in pixels is what it is, no matter a increase the operating system font-size or I zoom in/out. More than that, all the other browsers return consistent values for screen.width and screen.height so why is Firefox doing differently in this respect?

If you decide to go this path anyway, how can a developer find out what is the REAL screen size in pixels no matter what other settings might be (dpi, zoom, font-size, etc, etc) ???? I am asking because I am a developer myself and some of my websites make use of javascript functions that rely on the screen size in pixels to determine some aspects of the view to show.

Best regards

The screen size of my laptop is 1366 x 768 IE9, Chrome and Opera are all returning these values when using screen.width and screen.height On Chrome, even when you zoom in, the values being returned are still 1366 x 768 as they should be since the screen size of my laptop is what it is and does not "change" when you zoom in/out. Firefox 30.0 is returning 1093 x 614 !!!! WHY???? I made sure the zoom was reset (CTRL+0) and still the values are those... wrong! I played around with the DPI settings on Firefox (layout.css.devPixelsPerPx) to no avail. I must say that I am using Windows 7 with a higher font-size (125%). Could this be the problem???? If so, I do not understand why; again, my screen size in pixels is what it is, no matter a increase the operating system font-size or I zoom in/out. More than that, all the other browsers return consistent values for screen.width and screen.height so why is Firefox doing differently in this respect? If you decide to go this path anyway, how can a developer find out what is the REAL screen size in pixels no matter what other settings might be (dpi, zoom, font-size, etc, etc) ???? I am asking because I am a developer myself and some of my websites make use of javascript functions that rely on the screen size in pixels to determine some aspects of the view to show. Best regards

所有回复 (3)

more options

Firefox reports the screen estate that is available to websites and if the page is zoomed in some way then the returned values are adjusted (1366/1093=1.25 and 768/614=1.25)to reflect that. The same happens if the page is zoomed or if the DPI setting is changed otherwise.

more options

This page has an example of how to use the window.devicePixelRatio property to compute the true screen size:

http://dev.jeffersonscher.com/resolution.html

You probably should allow for rounding errors in the computation...

more options

Excellent! Thanks for pointing me to window.devicePixelRatio... This will make the trick for us.