Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
I

ios-inner-height

> 编程语言
Open source

Retrieve a consistent, accurate window.innerHeight measurement from iOS

195 stars0 likes0 views
WebsiteGitHub

About

Retrieve a consistent, accurate window.innerHeight measurement from iOS

ios-inner-height

Retrieve a consistent, accurate window.innerHeight measurement from iOS

iOS Safari has a neat feature that results in window.innerHeight providing different values based on whether or not the URL control and menu bar are expanded. This is the case when a page initially loads - or if the page content is shorter than the screen. As a user scrolls, the menu bar retracts beneath the perceivable screen and the URL control shrinks to increase the amount of the page now visible to the user.

For a better explanation, read "The iOS Safari menu bar is hostile to web apps: discuss".

This can get super annoying super quick when one wants to know the scrolled viewport height sans expanded URL and menu bar for, say, measuring an element's percentage in view. It seems the most reliable way to determine the window's inner height regardless of Safari's current scroll state is to inject an element into the DOM, set its height to 100vh, measure it, and destroy it.

This module provides a consistent pixel measurement for the state of iOS Safari having no menu bar and a collapsed URL control, independent of its actual state.

Example output

From an iOS device, load the example page. This page reports the current height returned by this module and by calling window.innerHeight.

reporter page load after scroll orientation change
ios-inner-height 628px 628px 375px
window.innerHeight 559px 628px 375px 331px

Measurements upon initial load and after scroll.

Measurements upon initial load and after scroll (landscape).

Installation

Install via npm:

bash
$ npm i -S ios-inner-height

Usage as a module

The module exposes a getter that can be called as often as you like. It will automatically account for the window's current orientation. And all measurements are done upon instantiation, so future calls should introduce zero DOM overhead.

javascript
var innerHeight = require('ios-inner-height');

// now anytime you need it, get a reliable window height
console.log(innerHeight());

Built file usage

A built file and its minififed version are included in the dist folder. This is a standard browserify standalone file. This file will work with other module systems and sets iosInnerHeight as a global method if no module system is found.

xml

  iOS Inner Height

  
iosInnerHeight measurement: 

  

  

Known issues

Tests are pretty horrible. Searching for a headless version of iOS Safari.

Resources

  • The Safari team's perspective.
  • Article "The iOS Safari menu bar is hostile to web apps: discuss"
  • Busting require's cache for testing with proxyquire

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言