|In this chapter you will learn :
- Window object.
- Properties and methods of window object.
- Pop-up windows
The following tables describe all the properties and methods of window object :
Properties of Window Object
||It specifies a Boolean value to indicate whether a window has been closed or not. It returns Boolean 'true', if the window is closed.
||This property sets or returns the default string message, displayed in the status bar of the window. The message will be displayed when the page loads.
||It refers to a document being displayed in a window. It also provides methods for displaying HTML output to the user.
||It refers to an array containing references to all the frames in the current window.
||It contains the information regarding all the URL's, the user has visited, within a window.
||This property determines the inner height (in pixels) of the window's display area.
||This property determines the inner width (in pixels) of the window's display area.
||It returns the total number of frames contained in a frameset or window.
||It represents the windows location bar which contains the details of the URL. The location bar property has its own property called visible, which has the default value true (visible) and it can be set to false (hidden).
||It represents the windows menu bar which contains the various pull-down menus ( File, Edit, View etc.). This property also has its own property called visible, which is by default true and can be set as false(hidden).
||It sets or returns the name of the window.
||It sets or returns a reference to a window object that causes a window to open.
||It refers to the window or frame whose frameset contains the current frame.
||It refers to the current active window or frame.
||It is a read-write property that allows you to refer to a temporary message appearing on the status bar.
||It refers to a top-level window in a series of windows.
||It refers to the current window or frame.
Methods of the Window Object
||It displays an alert dialog box with the appropriate message and OK button
||This function will take the focus away from the window.
||It clears the predefined timeout.
||This function will close the current or the specified window.
||It displays a confirm dialog box with the specified message and OK and Cancel buttons.
||It gives focus to a window and brings it to the front of the desktop.
|open (url, name, [options])
||It creates a window object and opens a new window.
|prompt (text, defaultInput)
||It displays a prompt dialog box with a message and an input field.
|scroll (x, y)
||It scrolls the window to the location specified by the X and Y values( in pixels).
|setTimeout (expression, milliseconds)
||This method executes an expression or calls a function once, after the interval of specified milliseconds has elapsed.
||It clears a timeout that was set with the setInterval method.
||This method moves the window by a specified amount in the horizontal and vertical direction ( in pixels ).
|moveTo (width, height)
||This method moves the window's left edge and top edge to the specified X an Y coordinates.
|resizeBy (horz, vert)
||It resizes the window by moving the bottom right corner.
|resizeTo (width, height)
||It adjusts the window by specified width and height dimensions.
|scrollBy (horz, vert)
||It scrolls the window by specified amount.
|scrollTo (x, y)
||It scrolls the window to a specific location.
|setInterval (function, time, [args] )
||It repeatedly invokes a function or evaluates an expression after a timeout, in milliseconds, expires.
||It stops the current window's downloading.
There are two methods used for opening and closing of the browser window, i.e., the open( ) and close( ) methods respectively. The open( ) method opens a new browser window at a specified URL and with a given set of options. The open( ) method invokes a newly created object in return. This object is usually assigned to a variable that is used to keep track of the window. The syntax of the open( ) method is
variable = open ( url, name, [options] )
Here, variable is the name of the variable assigned to the window object. url is the URL of the document that is to be opened in particular window, name is the name that is assigned to the window and options is used to define different features of the window. The name can also be supplied in the target attribute of a <form> or <a> tag.