Javascript Window Object

tutorial and example
tutorial and example

JavaScript Window Object

The window object represents a window in browser. An object of window is created automatically by the browser.

Window is the object of browser, it is not the object of JavaScript. The JavaScript objects are string, array, data etc.

It is used to display the popup dialog box such as alert box, confirm dialog box, input dialog box etc.

The window methods are mainly for opening and closing new windows.

Methods of window object

The following are the main methods.

Methods Description
alert() It display the alert box containing message with ok button.
confirm() It displays the confirm dialog box which contain message with ok and cancel button.
prompt() It display a dialog box to get input from the user.
Open() Open new window.
Close() Close current window.
setTimeout() It performs action after specified time like calling function, evaluating expressions etc.

Example of alert()

Try Now

Example of confirm()

Try Now

Example of prompt()

Try Now

Example of open()

Try Now

Example of setTimeout()

Try Now