Window Object
- Window object represents the browser’s window or potentially frame, that a document is displayed in.
- As long as a browser window is open, even if no document is loaded in the window, the window object is defined in the current model in memory.
- All global JavaScript variables, functions and objects automatically become members of the window object.
Dialog boxes
It is used to provide some information to users.
Type of Dialog box:-
- Alert
- Confirm
- Prompt
alert ( ) Method
This Window object’s method is used to display data in the alert dialog box. alert really should be used only when you truly want to stop everything and let the user know something.
Syntax:- window.alert( ) or alert ( )
confirm ( ) Method
This Window object’s method is used to display a message for a user to respond to by pressing either an OK button to agree with the message to a Cancel button to disagree with the message. It returns true on OK and false on Cancel.
Syntax:- window.confirm( ) or confirm ( )
prompt ( ) Method
Window object’s method prompt() can be used to get input from the user, named prompt. The prompt( ) method displays a dialog box that prompts the visitor for input.
Once the prompt function obtains input from the user, it returns that input. If the user press the cancel button in the dialog or close box, a value null will be returned.
Syntax: – prompt(text, defaultText)
open ( ) Method
The open( ) method creates a new secondary browser window, similar to choosing New Window from the File menu. It returns a Window object representing the newly-created window. If the window couldn’t be opened, the returned value is instead null.
Syntax: – window.open (URL, name, features, replace)
URL – URL indicates the document to load into the window. If no URL is specified, a new window with about: blank is opened
Name – Specifies the target attribute or the name of the window. The following values are supported:
_blank – URL is loaded into a new window. This is default
_parent – URL is loaded into the parent frame
_self – URL replaces the current page
_top – URL replaces any framesets that may be loaded
open ( ) Method
Syntax: – window.open (URL, name, features, replace)
Features – It is a comma-delimited string that lists the features of the window.
Replace – It indicates whether or not the URL specified should replace the window’s contents. This would apply to a window that was already created. Value can be true/false.
Features
Feature Parameter | Value | Example |
alwaysLowered | yes/no | alwaysLowered=yes |
alwaysRaised | yes/no | alwaysRaised=no |
centerscreen | yes/no | centerscreen=yes |
chrome | yes/no | chrome=yes/true |
close | yes/no | close=no |
dialog | yes/no | dialog=yes |
dependent | yes/no | dependent=yes |
z-lock | yes/no | z-lock=yes |
hotkeys | yes/no | hotkeys=yes |
Features
Feature Parameter | Value | Example |
location | yes/no | location=no |
menubar | yes/no | menubar=no |
minimizable | yes/no | minimizable=no |
modal | yes/no | modal=yes |
personalbar | yes/no | personalbar=yes/true |
resizable | yes/no | resizable=no |
scrollbars | yes/no | scrollbars=no |
status | yes/no | status=no |
titlebar | yes/no | titlebar=yes |
Features
Feature Parameter | Value | Example |
toolbar | yes/no | toolbar=yes |
top | pixel value | top=20 |
height | pixel value | height=200 |
width | pixel value | width=200 |
innerHeight | pixel value | innerHeight=200 |
innerWidth | pixel value | innerWidth=200 |
outerHeight | pixel value | outerHeight=200 |
outerWidth | pixel value | outerWidth=200 |
left | pixel value | left=20 |
close ( ) Method
Once a window is open, the close ( ) method is used to close it. It closes the current window or the window on which it was called. This method is only allowed to be called for windows that were opened by a script using the window.open() method. It is often used together with open ( ) method.
Syntax: – window.close ( )
- How to get Blackduck Trial version? - December 3, 2023
- PHP ionCube Error: cannot be decoded by this version of the ionCube Loader - December 2, 2023
- Cloudbees CD/RO Error: ectool - November 24, 2023