Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

Mulongo oyo etiyamaki na archive. Tuna motuna mosusu soki osengeli na lisalisi

Mozilla returns wrong screen size

  • 3 biyano
  • 1 eza na nkokoso oyo
  • 1 view
  • Eyano yasuka ya 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

All Replies (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.