Animations

API

Arrays

Async

Basics

Challenges

Classes

Console

Dates

Debugging

DOM Elements

DOM Methods

DOM Navigation

DOM Properties

Event Listeners

Flow Control

Forms

Functions

Global Functions

JSON

Keywords

Libraries (3rd party)

Math

Modules

Objects

Snippets

String

Types

Widgets

Window Object

JavaScript - Inner Height / Inner Width

Two properties can be used to determine the size of the browser window. The browser window (the browser viewport) is NOT including toolbars and scrollbars.

  • window.innerHeight - the inner height of the browser window (in pixels)
  • window.innerWidth - the inner width of the browser window (in pixels)

let output = "";
let Window =
{
    InnerWidth: window.innerWidth,
    InnerHeight: window.innerHeight
};

output += "InnerWidth: " + Window.InnerWidth + "<br />";
output += "InnerHeight: " + Window.InnerHeight + "<br />";
document.getElementById("demo1").innerHTML = output;