Beruflich Dokumente
Kultur Dokumente
Chapter Nine
This chapter demonstrates properties and methods of the
window object. Creating pop-up windows is illustrated and the
use of framed pages is also discussed with examples of how to
address objects in other frames.
Covers
Confirm 98
Prompt 99
Location 100
History 101
Onload 102
Status 103
Pop-up window 104
Pop-up features 105
Close pop-up 106
Get size 107
Frames array 108
Frame objects 109
Error handling 110
Confirm
The alert() function that is used extensively in the code examples
given throughout this book is actually a method of the top-level
window object, so may be correctly addressed as window.alert()
window.alert().
The window.confirm() method is the first of two other window
methods that produce dialog boxes when called.
It is used to get user confirmation from a dialog box containing an
OK button that returns true to the script and a Cancel button that
returns false to the script.
A single argument should be passed to the method as a text string
containing the question for the user to confirm.
This example demonstrates the window.confirm() method
performing conditional branching to determine which message
string to write – depending upon which button the user pushes in
the confirm dialog box:
9. Window properties 99
Location
The window.location object contains the full URL address of the
document that is currently loaded in the browser.
It stores the actual full URL in the window.location.href property
and assigning a new value to this, or to the window.location object
itself, will load the specified URL into the browser.
A typical URL address may comprise these parts:
The second
argument must
be an empty
string if no name
is being given to
the pop-up window.
Feature Description