Om de ûnderfining foar jo te ferbetterjen is tydlik de funksjonaliteit dan dizze website troch ûnderhâldswurk beheind. Wannear in artikel jo probleem net oplost en jo in fraach stelle wolle, kin ús stipemienskip jo helpe yn @FirefoxSupport op Twitter en /r/firefox op Reddit.

Sykje yn Support

Mij stipescams. Wy sille jo nea freegje in telefoannûmer te beljen, der in sms nei ta te stjoeren of persoanlike gegevens te dielen. Meld fertochte aktiviteit mei de opsje ‘Misbrûk melde’.

Mear ynfo

Dizze konversaasje is argivearre. Stel in nije fraach as jo help nedich hawwe.

Mozilla returns wrong screen size

  • 3 antwurd
  • 1 hat dit probleem
  • 1 werjefte
  • Lêste antwurd fan 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

Alle antwurden (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.