搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

Firefox 22 has a broken javascript screen.height detection

  • 5 回覆
  • 15 有這個問題
  • 1 次檢視
  • 最近回覆由 DA Ward

more options

my website detects the browsers' screen size by accessing javascript screen.height and screen.width at the first page load. Upon changing to Firefox 22 from 21, this feature is broken. It now detects a 1280 by 800 laptop as 1024 by 640 which ruins the site presentation. Chrome and IE both detect the screen height and width correctly, as did Firefox 21.

my website detects the browsers' screen size by accessing javascript screen.height and screen.width at the first page load. Upon changing to Firefox 22 from 21, this feature is broken. It now detects a 1280 by 800 laptop as 1024 by 640 which ruins the site presentation. Chrome and IE both detect the screen height and width correctly, as did Firefox 21.

所有回覆 (5)

more options

hello, firefox 22 is now respecting the pixel density you've set on a system level in the windows control panel > appearance > display. more information about that is available at http://windows.microsoft.com/en-us/windows7/make-the-text-on-your-screen-larger-or-smaller

if you want to set the text size/pixel density in firefox different from that of your system's settings like it was handled in prior versions, enter about:config into the firefox address bar (confirm the info message in case it shows up) & search for the preference named layout.css.devPixelsPerPx. double-click it and change its value to 1.0 (or any other zoom factor that fits your purpose: 1.0 relates to 100%, 0.8 equals 80% and so on; -1.0 is the default value and will adhere to the system settings).

more options

Make sure that you aren't zooming those pages.

Reset the page zoom on pages that cause problems.

  • View > Zoom > Reset (Ctrl+0 (zero); Command+0 on Mac)
more options

Thanks. There was no Appearance icon on my Control Panel, but I actually found the settings under "Ease of Access Center > Make this Computer Easier to See > Change the Size of Text and Icons. That brought up the "DPI Scaling Control Panel", which allowed me to reset the screen to 96 dpi from 120 dpi.

All 3 browsers now agree that the screen size is 1280 by 800. But still, in the case of users who have a desktop or laptop set to 120 dpi: advertant or not, Firefox 22 is the only browser that is going to misidentify their screen size to the Javascript engine. That's sad, because much of the web depends on javascript's evaluation of the user's screen size....

more options

hello, but if the dpi preference is set to 120 on a system level, then firefox will now also display web-content with this scaling. as a web developer you probably want to know & adapt to the size that is observable by the user and not the technical specifications of the screen he's using.

more options

No:

As a web developer, you are mainly concerned with the page fitting the user's screen. Whether that page contains big, fuzzy letters, or small sharp ones is secondary, and was actually the user's choice. If the 3 major browsers could agree on notifying the javascript engine about the user's actual resolution, it would be fine.

Looks like I will have to go back to individually identifying browsers, and computing the web page dimensions differently for each....