What is viewport in HTML.

minil picture minil · May 30, 2010 · Viewed 43.3k times · Source

What is viewport in HTML? Could you give some examples on how to access the viewport details?

Answer

Matchu picture Matchu · May 30, 2010

The viewport is the part of the webpage that the user can currently see. The scrollbars move the viewport to show other parts of the page.

Follow this article's instructions to get the viewport dimensions in Javascript.

if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }