How to determine actual viewport width and height on iOS

Viewed 7235

I've been stuck at such easy task as determine page width and height on iOS when the page is zoomed by the user.

The problem is that some web sites has strange layout and looks like this:

enter image description here

This is a not scaled page and it has resolution of 1164x1811 pixels and that's correct. I've got these values from window.innerWidth and window.innerHeight. Highlighted area is a body element and it has resolution of 1024x1594 pixels, that matters.

Next I use pinch-to-zoom to zoom page in and this is how it looks:

enter image description here

Now, when I trying to get page size I got 1024x1594 pixels from window.innerWidth and window.innerHeight respectively. These values are exact same to body size.

So the question is how to get the right page size whether with zoom or not.

I've tested this particular case in Chrome as well and get correct result: it's always 1164x1811 pixels regardless to zoom.

2 Answers
Related