The window object * * * has seven properties:
● defauleStatus: specifies the information in the status bar of the window.
● status: specifies the information in the status bar of the current window.
● Frames: it is an array, and the content is all the frames in the window.
● Parent window: refers to the parent window of the current window.
● Self: refers to the current window.
● top: represents the top-level window of all current windows.
● Window: represents the current window.
There are five methods for window objects:
● Alarm: a dialog box with "OK" button is displayed.
● Confirm: Displays the "OK" and "Cancel" dialog boxes.
● Tip: Displays a dialog box with an input area.
● Open: Open a new window.
● Close: Close the window opened by the user.
3. Example of status attribute, displaying and clearing text in the status bar of the window.
Click the "Write Text" button to display "This is the status bar" in the status bar. Click the Clear Text button to clear the text in the status bar.
& lthtml & gt
& lthead & gt
& lt scripting language = "JavaScript">
Function statbar(txt) {
window.status = txt}
& lt/script & gt;
& lt/head & gt;
& ltbody & gt
& lt form & gt
& lt input type = "button" name = "look" value = "writentext" onclick = "statbar ('this is the status bar');" & gt
& ltinput type = " button " name = " erase " value = " clear text " onclick = " statbar('); "& gt
& lt/form & gt;
& lt/body & gt;
& lt/html & gt;
Example of alert method: It shows "Let's learn JavaScript scripting language." Dialog box of.
& lthtml & gt
& ltbody & gt
& lt scripting language = "JavaScript">
Alert ("Let's learn the JavaScript scripting language." )
& lt/script & gt;
& lt/body & gt;
& lt/html & gt;
Example of confirmation method: let the user choose whether to go to the next page.
Use the confirmation to display the selection dialog box, press "OK" to enter the next.htm, and press "Cancel" not to enter.
& lthtml & gt
& ltbody & gt
& lt scripting language = "JavaScript">
If (OK ("Do you want to go to the next page?" ))
location="next.htm "
& lt/script & gt;
& lt/body & gt;
& lt/html & gt;
6. Example of prompt method: let the user enter the name and display it.
Use prompt to display the input dialog box, let the user enter the name, and then use alert dialog box to display.
& lthtml & gt
& ltbody & gt
& lt scripting language = "JavaScript">
Var name
Name=prompt ("Please enter your name", "Zhang Guoqiang")
Alert ("Hello,"+name)
& lt/script & gt;
& lt/body & gt;
& lt/html & gt;
Seven, window object method example
When you open a webpage, immediately open another window, showing test.htm.
& lthtml & gt
& ltbody onload = " JavaScript:window . open(' test . htm ')" & gt;
& lt/body & gt;
& lt/html & gt;
VIII. Attributes and Methods of Historical Objects
The History object has only one length property, which indicates the number of links in the history object.
Historical objects have the following methods:
● Back: Displays the previous page in the browser.
● Forward: display the upper and lower pages in the browser.
● go(int): load the int page from the current browser.
9. Historical example: a page with "Previous Page" and "Next Page" buttons.
& lthtml & gt
& ltbody & gt
& lt form & gt
& ltinput type = " button " value = " previous page " onClick = " history . back()" & gt;
& ltinput type = " button " value = " next page " onClick = " history . forward()" & gt;
& lt/body & gt;
& lt/html & gt;