M
M
miner21002022-02-26 06:44:57
JavaScript
miner2100, 2022-02-26 06:44:57

Why different ViewPort sizes in Chrome and Firefox?

I'm trying to take a screenshot in Goole Chrome via the Chrome.Tab API - captureVisibleTab.
I look at the parameters of the visible part of the image

>screen
Screen {availWidth: 1438, availHeight: 1150, width: 1436, height: 1149, colorDepth: 24, …}
availHeight: 1150
availLeft: 1437
availTop: 0
availWidth: 1438
colorDepth: 24
height: 1149
orientation: ScreenOrientation {angle: 0, type: 'landscape-primary', onchange: null}
pixelDepth: 24
width: 1436
: Screen


I see the same thing in Firefox:
>screen
Screen { availWidth: 1280, availHeight: 1024, width: 1280, height: 1024, colorDepth: 24, pixelDepth: 24, top: 0, left: 0, availTop: 0, availLeft: 0 }


Slightly goofing off and trying to google.
Interestingly, in Chrome captureVisibleTab gives a picture with real screen dimensions - 1281 x 1046. I did not try to capture the screen in Firefox.

And the question is: how to find out the real dimensions of the ViewPort in Chrome?
document.documentElement.clientHeight and document.documentElement.clientWidth are not real values!

Chrome 98.0.4758.102
Firefox 97.0 (64 bits)
OS Ubuntu 18.04 with Mate Desktop.
Desktop on two monitors

ps: after rebooting the system, chrome determined the correct dimensions of the ViewPort! It's still not clear, because with an incorrectly defined ViewPort, all sites were displayed without distortion.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kentavr16, 2022-02-26
@Kentavr16

availHeight is css pixels , which are indirectly related to real ones. Try zooming in the developer console and sipping the screen border while changing the resolution. There will also not be real numbers)
but about .documentElement.clientHeight
documentation on MDN

M
miner2100, 2022-03-19
@miner2100

In short, Chrome for some reason incorrectly determines the display settings.
Left mate for cinamon. In cinamon, while the parameters are determined by Chrome correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question