Skip to Content
Platform.Ontology

Viewport meta and visual viewport

visualViewport reports pinch-zoom scale and on-screen keyboard offsets.

Gets silentlyScreen and windowsWindowWeb browsersWhen the page loadsWhile you use it

In one line

Can see your pinch zoom level and when the on screen keyboard pops up

visualViewport reports pinch-zoom scale and on-screen keyboard offsets.

Scale above 1 tells the person is zoomed in (accessibility); height shrink exposes the on-screen keyboard. Updates live as the user pinches or types.

What it can and can't do

What the user does: You pinch to zoom, or tap a box that opens the keyboard.

It can

  • Check your current pinch zoom scale
  • See changes to the visible area, such as when the keyboard opens
  • Move buttons so they stay above the keyboard

It cannot

  • See what you type on the keyboard
  • Tell which keyboard app you use
  • Zoom the page for you

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported612017-09-05None
EdgeSupported792020-01-15None
FirefoxSupported912021-08-10None
SafariSupported132019-09-19None
Safari on iPhoneSupported132019-09-19None
Chrome on AndroidSupported612017-09-05None
Samsung InternetSupported8.02018-07-18None

How a site asks for it

APIwindow.visualViewport.scale, width, height, offsetTop, 'resize' event
Browser compat keysapi.VisualViewport
How access is grantednone
What the user seesNone
Needs a secure context (HTTPS)No
Needs a user gestureNo
How long it lastsread fresh on every page load; nothing stored
How to take it backnone needed (no grant)
Inside an iframeReadable from cross-origin iframes too (same values)

Typical flow

  1. Page script reads the value
  2. No prompt is shown

Data you get

Shape: object
How often: static per session

FieldTypeUnitRangePrecision
scalefloatratio0.25 to 50.01
width, heightfloatCSS pxNot listedsub-pixel

Technical limits

  • Browser pinch scale differs per OS

The story

What it is

Reports pinch zoom level and how far the on screen keyboard has pushed the page.

For you

You never see the reading. It is why a chat box slides up neatly above the keyboard when you start typing on your phone.

For makers

Makers use it to keep inputs visible and to adapt to zoom. The same numbers can show how a person holds and uses a device, which fraud teams can use.

Where you see it

TypeExampleApps
messagingA chat site lifts the message box above the on screen keyboard so you can see what you type.WhatsApp Web, Slack
gamesA browser game keeps its controls on screen when the keyboard opens for chat.None named
mapsA web map redraws labels when you pinch to zoom.Google Maps
shoppingA checkout form scrolls the card number field into view when the keyboard pops up.None named
securityA bot check sees a browser that never pinch zooms or shows a keyboard on a supposed phone.None named
accessibilityA site keeps text readable when a user zooms in a lot.None named
creativeA drawing app tells drawing taps apart from zoom gestures.None named

Risks

  • Behavior fingerprint
  • Reveals zoom use

What the platform says

  • MDN: Visual Viewport API. Explains how a page can read the part of the page currently visible, including zoom and keyboard changes.

Good uses and abuse

Legitimate uses

  • Keyboard-aware UI

Known abuse

  • Zoom behavior

Scores

ScoreValueMeaning
Sensitivity1 of 5How revealing the data is
Utility3 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bits1Rough identifying entropy, when known

Sources

How well checked: Based on official documentation.

On this page