The window object represents a Web browser window. It has several properties and methods, which helps us to extract information about the Web browser and enhance our web pages.
|A boolean value tells us whether the window has been closed
|The text that appears on the status bar
|A reference to the document object
|A reference to the history object
|A reference to the location object
|A reference to the navigator object
|Refers to the window that opened the current window
|Returns the available width of the browser window
|Returns the available height of the browser window
|A reference to the current window object
|Shows a pop up message
|Takes you back to the previous window
|Removes the focus from a window
|Cancels the timer set with the setInterval()
|Cancels the timer set with the setTimeout()
|Closes the browsers window
|A dialogue box is displayed, which allows the user to click the OK button or Cancel button
|Moves forward one window
|Opens a new browser window
|Pints the content shown on the window
|A prompt dialogue box is displayed, which allows the user to input data
|Calls a function each time the specified time (millisecond) passes
|Calls a function after a specified time (millisecond) has passed
The open() method requires three string arguments. The first argument is the URL address, the second argument is a name for the window and the third argument contains a list of features (see the table below).
|Sets the windows height
|Sets the x coordinate of the window
|Allows the window to be resized
|Adds the scrolbars
|Adds the status bar
|Adds the Forward and Back buttons bar
|Sets the y coordinate of the window
|Sets the windows width
You can also use the values "1" for yes and "2" for no.
The window object has a property called location, which refers to the location object. The location object is the child of the window object.
The location displays the full URL address of the document that is currently loaded in the browser window.
If you click the button it will take you to the top of this web page.
The history object stores a list of history of all the pages that have been visited in the current session. The history object is the child of the window object.
The example below shows the methods: back(), forward() and go(). The go() method takes an integer as a parameter - a positive number goes forward and a negative number goes backwards.
Inside the parentheses you can enter the number of pages you want to go back or forward.
The history object has a propety called length, it returns the number of URLs that are in the history list.
The navigator object contains the information about the current Web browser. The navigator object is the child of the window object.
It has several properties and methods but we are only going to look at the appCodeName property and the javaEnable() method.
The appCodeName property gives us the code name of the browser.
The javaEnable() method allows us to check if the java has been enabled in the browser; it returns a boolean value true.
The screen object provides information about the user's monitor resolution and the size of the display. The screen object is also the child of the window object.
|Returns the available height of the display screen - excludes the desktop task bar
|Returns the available width of the display screen - excludes the desktop task bar
|Returns the bit value of the ranges of colors that can be displayed
|Returns the height of the display screen
|Returns the width of the display screen
The document object is also a child of the window object. It provides access to the HTML document. The document object has so many properties and methods but we are only going to look at the property innerHTML and a few of the methods.
The innerHTML property is used when you want to change or insert content inside an HTML element.
Today, I saw a big lion at the zoo.
|Returns the first element that is represented by the id
|Returns references to the elements with the class name
|Returns a collection of elements represented by the name
|Returns a collection of elements represented by the tag name
|The write method is used when you want to write text in a HTML document
|The writeln method writes text in a HTML document and adds a new line after each statement
Tea Coffee Hot Chocolate