2

I've been trying to get the viewport height using jQuery in mobile Chrome, however this is returning a different result when the address bar is/isn't present.

I'm testing on Browserstack using Samsung Galaxy S5. When i scroll down and release so the address bar in Chrome is hidden I get a different reading to when the page loads or i'm scrolling up and the address bar is visible.

Is there a way to get the same height value regardless of whether the address bar is visible?

nb. I do have the doctype set

My code is:

$(window).resize(logHeight);
function logHeight() {
    console.log($(window).height());
    console.log($(document).height());
}
logHeight();
eh21
  • 51
  • 10
  • Try using `window.innerHeight` (`$(window).innerHeight()` in jq) – A. Wolff Sep 01 '16 at 16:20
  • Hi, i've tried that too, but still get different results for when the address bar is/isn't showing [screenshot](https://postimg.org/image/nj7bo7u6j/) – eh21 Sep 01 '16 at 17:10
  • You should anyway test it on true device or at least using other emulator, maybe issue is relevant to emulator – A. Wolff Sep 01 '16 at 17:24
  • The browserstack testing is streamed from an actual device. However I tried on a physical device now still with the same outcome. – eh21 Sep 02 '16 at 07:41

0 Answers0