HTML DOM Document defaultView property

Definition and usage

defaultView The property returns the Window Object.

See also:

Window Object

Instance

Example 1

Get the window object of the document:

const view = document.defaultView;

Try it yourself

Example 2

Get the window size:

const view = document.defaultView;
let width = view.innerWidth;
let height = view.innerHeight;

Try it yourself

Syntax

document.defaultView

Return value

Type Description
Object The window object of the document.

Browser support

document.defaultView It is a feature of DOM Level 1 (1998).

All browsers support it:

Chrome IE Edge Firefox Safari Opera
Chrome IE Edge Firefox Safari Opera
Support 9-11 Support Support Support Support