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, date etc.
The important methods of window object are as follows:
Method | Description |
---|---|
alert() | displays the alert box containing message with ok button. |
confirm() | displays the confirm dialog box containing message with ok and cancel button. |
prompt() | displays a dialog box to get input from the user. |
open() | opens the new window. |
close() | closes the current window. |
setTimeout() | performs action after specified time like calling function, evaluating expressions etc. |
It displays alert dialog box. It has message and ok button.
See this example:
Output:
It displays the confirm dialog box. It has message with ok and cancel buttons.
See this example:
Output:
It displays prompt dialog box for input. It has message and textfield.
It displays the content in a new window.
It performs its task after the given milliseconds.