'offsetHeight, clientHeight and scrollHeight or offsetWidth, clientWidth and scrollWidth return wrong value for Mackbook retina display
I am trying to get retina display document size through JavaScript code
var size = {
width: Math.max(
document.documentElement.clientWidth,
document.body.scrollWidth,
document.documentElement.scrollWidth,
document.body.offsetWidth,
document.documentElement.offsetWidth
),
height: Math.max(
document.documentElement.clientHeight,
document.body.scrollHeight,
document.documentElement.scrollHeight,
document.body.offsetHeight,
document.documentElement.offsetHeight
)
};
but it will give only half image size in retina display, its working fine on other display any suggestion how to get clientWidth ,scrollWidth etc for retina display through javascript
Solution 1:[1]
Retina sets devicePixelRatio to 2 if you multiply your heights and widths by this parameter (which is in most cases 1), you get your proper value.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ouflak |
