Window object Properties
- closed - A boolean value that indicates whether the window is closed.
- defaultStatus - This is the default message that is loaded into the status bar when the window loads.
window.defaultStatus = "Click on a link on the left to navigate this website."
- length - The number of frames that the window contains.
- name The window name.
- opener The object that caused the window to open.
- status - The status bar is the bar on the lower left side of the browser and is used to display temporary messages. The below example will write a message to the status bar
window.status = "This message will display in the window status bar."
The window status bar will not always work when written to immediately when the page loads. Normally it is used when an event happens such as when the user clicks on something or moves the mouse over an item or area on the page. The following code will display a status bar message when the mouse is moved over the home button.
<a href="../../../../index.html" target="_top" onMouseOver="window.status='This will take you to the Home Page' ;return true" onMouseOut="window.status='Hey! You are not holding the mouse on the Home Button!';return true"><img SRC="../../../../gifs/greenhomebutton2.gif" ALT="Home" VSPACE=3 BORDER=0 height=35 width=120></a><BR>
Window Object Methods
- alert("message") - The string passed to the alert function is displayed in an alert dialog box.
alert("This is a test")
- blur() - This function will take the focus away from the window. Calling it as follows will perform the function.
- clearInterval(interval) - Clear the timeout interval.
- clearInterval(timeID) - Removes a repetative timeout that was set up using the setInterval function. the ID value must be passed to the function.
- clearTimeout(timeID) - Remove a timeout that was set using the setTimeout function.
- close() - This function will close the current window or the named window. Normally a form button is provided to allow the user to close the window and the function is called by the onClick action. Otherwise some other event may be used to close the window.
- confirm("message") The string passed to the confirm function is displayed in the confirm dialog box. The dialog box returns a true or false value depending on which button was clicked.
if (confirm("Are you sure?"))
document.write("You were sure!")
document.write("You were not sure!")
- focus() - This function will give the focus to the window.
- moveBy(x,y) - The window is moved the specified number of pixels in the X and Y direction.
- moveTo(x,y) - The window is moved to the specified X and Y pixel location in the browser.
- open("URLname","Windowname",["options"]) - A new window is opened with the name specified by the second parameter. The document specified by the first parameter is loaded. The options are not required, and may be set to values of yes or now as in the below example. Many options are set to default values depending on whether others are set. For example, if the width and height are specified, the resizable option is set as default to no. Also if the toolbar is off, the menubar is set to default of no. The options are:
- alwaysRaised - If yes, the created window is raised.
- directories - The value of yes or no determines if the window shows directory buttons or not.
- height - Specifies the window height in pixels. This is set to an integer value, rather than yes or no.
- left - Specifies the distance in pixels the new window will be placed from the left side of the screen. This is set to an integer value, rather than yes or no.
- location - The value of yes or no determines if the window has a location displayed on the address line (or has an address line) or not.
- menubar - The value of yes or no determines if the window has a menubar or not.
- outerWidth - Specifies the outer window width in pixels. This is set to an integer value, rather than yes or no.
- outerHeight - Specifies the outer window height in pixels. This is set to an integer value, rather than yes or no.
- resizable - The value of yes or no determines if the window can be resized by the user or not
- status - The value of yes or no determines if the window has a status bar or not.
- scrollbars - The value of yes or no determines if the window has scroll bars or not.
- toolbar - The value of yes or no determines if the window has a toolbar or not.
- top - Specifies the distance in pixels the new window will be placed from the top of the screen. This is set to an integer value, rather than yes or no.
- width - Specifies the window width in pixels. This is set to an integer value, rather than yes or no.
- z-lock - If yes, the created window is in the background.
- prompt("message","defaultmessage") - A prompt dialog box is displayed with the message passed as the prompt question or phrase. The defaultmessage appears in the box, to be replaced by user entered text. If no default message string is present, no default string is displayed.
- resizeBy(X,Y) - Adjusts the window size relative to the current value.
- resizeTo(X,Y) - Adjusts the window size to set X and Y width and height values.
- scroll(X,Y) - The window is scrolled to the location specified by the X and Y values in pixels.
- scrollBy(X, Y)
- setInterval(function(),milliseconds,[functargs]) - Cause a function to be called periodically based on the time value specified. The functargs are arguments passed to the function.
- setTimeout(function(),milliseconds,[functargs]) - Used to call a function after the specified time in milliseconds. If you put the following code in your HTML body start tag:
<body onLoad="timeID = setTimeout('showMessage()',4000)">
And put this code inside your HEAD element:
alert("It has been 4 seconds since this page loaded.")
Your page will display the alert message four seconds after it loads.
- Option - object
- parent - The parent window of the current window.
- screen - object
- self - The current window.
- top - The top window in a list of framed windows.
- window - the current window.
- document - The document currently being displayed in the window object.
- frame - This is the name of a frame that refers to a single frame in a frameset.
- history - The window's history object which is the list of URLs that the current window has loaded. Its methods include:
- back() - The same as using the back button on the browser, causes the previous document to be loaded.
- forward() - The same effect as using the forward button on the browser, the next document in the history list is loaded if there is one.
- go(number) - A numeric value may be passed to this function. If the numeric value is 0, the current document is reloaded. If it is above 0, the document the correct number of entries ahead in the history list is loaded. If the value is negative a document the correct number of entries back in the history list is loaded.
- location - The location object of the window.