Septagram
Septagram

Reputation: 9795

How to get the viewport size in real device pixels?

There are screen.width and screen.height properties, that contain the screen width and height in real device pixels. However, they do not account for parts of the screen being taken by things not from the webpage, such as phone's status bar and browser's address bar / tab name with a button to expand the list of tabs. Is there any way at all to find out how much screen real estate does the browser actually allocates to the viewport?

Upvotes: 1

Views: 2272

Answers (1)

Chirag Bhatia - chirag64
Chirag Bhatia - chirag64

Reputation: 4526

window.innerWidth will provide you the width of the viewport.

window.innerHeight will provide you the height of the viewport.

Upvotes: 3

Related Questions