Android browser's screen.width, screen.height & window.innerWidth & window.innerHeight are unreliable Android browser's screen.width, screen.height & window.innerWidth & window.innerHeight are unreliable android android

Android browser's screen.width, screen.height & window.innerWidth & window.innerHeight are unreliable


On Android, window.outerWidth and window.outerHeight are reliably the screen size. Depending on your version of Android, innerWidth/Height is usually incorrect.

Here's a really good writeup on the situation.


Below is differentiation based on readings with Samsung Tab running Android 4.1

  • screen.height - gives actual device height including task bar andtitle bar

  • window.innerHeight - gives the height excluding task bar, title barand address bar(if visible)

  • window.outerHeight - gives the height excluding task bar and titlebar height, (no matter address bar is visible or hidden, outerHeightinclude the address bar height.)


I'm using this to make it work between ios and android.

var screenHeight = (ionic.Platform.isIOS()) ? window.screen.height : window.innerHeight * window.devicePixelRatio;