LILLY ROBOT |
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.
Property | Description |
---|---|
closed | A boolean value tells us whether the window has been closed |
defaultStatus | The text that appears on the status bar |
document | A reference to the document object |
history | A reference to the history object |
location | A reference to the location object |
navigator | A reference to the navigator object |
opener | Refers to the window that opened the current window |
screen.availWidth | Returns the available width of the browser window |
screen.availHeight | Returns the available height of the browser window |
window | A reference to the current window object |
Displays
Displays
Method | Description |
---|---|
alert() | Shows a pop up message |
back() | Takes you back to the previous window |
blur() | Removes the focus from a window |
clearInterval() | Cancels the timer set with the setInterval() |
clearTimeout() | Cancels the timer set with the setTimeout() |
close() | Closes the browsers window |
confirm() | A dialogue box is displayed, which allows the user to click the OK button or Cancel button |
forward() | Moves forward one window |
open() | Opens a new browser window |
print() | Pints the content shown on the window |
prompt() | A prompt dialogue box is displayed, which allows the user to input data |
setInterval() | Calls a function each time the specified time (millisecond) passes |
setTimeout() | Calls a function after a specified time (millisecond) has passed |
Displays
Displays
Displays
Displays
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).
Features | Description | Values |
---|---|---|
height | Sets the windows height | in pixels |
left | Sets the x coordinate of the window | in pixels |
resizable | Allows the window to be resized | yes/no |
scrollbars | Adds the scrolbars | yes/no |
status | Adds the status bar | yes/no |
toolbar | Adds the Forward and Back buttons bar | yes/no |
top | Sets the y coordinate of the window | in pixels |
width | Sets the windows width | in pixels |
You can also use the values "1" for yes and "2" for no.
Displays
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.
Displays
If you click the button it will take you to the top of this web page.
Displays
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.
Displays
The history object has a propety called length, it returns the number of URLs that are in the history list.
Displays
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.
Displays
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.
Property | Description |
---|---|
availHeight | Returns the available height of the display screen - excludes the desktop task bar |
availWidth | Returns the available width of the display screen - excludes the desktop task bar |
colorDepth | Returns the bit value of the ranges of colors that can be displayed |
height | Returns the height of the display screen |
width | Returns the width of the display screen |
Displays
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.
Displays
Today, I saw a big lion at the zoo.
Method | Description |
---|---|
getElementById(id) | Returns the first element that is represented by the id |
getElementByClassName(class name) | Returns references to the elements with the class name |
getElementByName(name) | Returns a collection of elements represented by the name |
getElementByTagName(tag name) | Returns a collection of elements represented by the tag name |
write() | The write method is used when you want to write text in a HTML document |
writeln() | The writeln method writes text in a HTML document and adds a new line after each statement |
Displays
Displays
Displays
Displays
Tea Coffee Hot Chocolate