HTML DOM Document defaultView

Example

Get the document's window object:

const view = document.defaultView;
Try it Yourself »

Get the size of the window:

const view = document.defaultView;
let width = view.innerWidth;
let height = view.innerHeight;
Try it Yourself »

Description

The defaultView property returns the document's window object.

See Also:

The Window Object


Syntax

document.defaultView

Return Value

Type Description
ObjectThe document's Window Object

Browser Support

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

It is fully supported in all browsers:

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


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.