Important Notice: We're experiencing email notification issues. If you've posted a question in the community forums recently, please check your profile manually for responses while we're working to fix this.

On Monday the 3rd of March, around 5pm UTC (9am PT) users may experience a brief period of downtime while one of our underlying services is under maintenance.

Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Tìm hiểu thêm

Mozilla returns wrong screen size

  • 3 trả lời
  • 1 gặp vấn đề này
  • 1 lượt xem
  • Trả lời mới nhất được viết bởi 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

Tất cả các câu trả lời (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.