HTML and CSS Reference
In-Depth Information
Table 9-1 Built-In JavaScript Objects (continued)
Object
Description
DOM
All elements related to the Document Object Model
Function
Accesses information about specific functions
History
Keeps track of Web pages visited
Location
Switches to a new Web page
Math
Performs calculations
Navigator
Obtains information about the current Web browser
Number
Supports special constants
Object
Creates an Object wrapper
RegExp
Describes patterns of characters
Screen
Gives platform-specific information about the user's screen
String
Represents a set of characters
Window
Represents a browser window
JavaScript objects have properties and methods. Properties are attributes that
describe an object's characteristics. As shown in Table 9-2, an object and its property are
written by separating the object from its property with a period. A specific value can be
assigned to a property, as shown in the following example:
Other Scripting
Languages
Although JavaScript and
VBScript are the two
main client-side script
languages used today,
there are over a dozen
other scripting languages
that work on specific
platforms or operating
systems. For example, PHP
and Perl. Perl stands for
Practical Extraction and
Report Language, and was
developed by Larry Wall in
1987 while at Unisys.
truck.style=”pickup”
where the truck is the object, style is the property, and pickup is the value assigned to the
property.
Table 9-2 Object and Property
General form:
object.property
Comment:
where the object is stated first, then a period, then the descriptive property . A value can be
assigned to the property, or the property can return a value, as shown in the examples below.
In some cases, an object can be a property of a superior object, such as a text field that
belongs to a form.
Examples:
myForm.fname.style.backgroundColor=”#ff0000”
browser=navigator.appName
Methods are actions that an object can perform. For example, methods associated
with the truck object might be style, color, and model. An object and one of its methods
would be written as:
Object Inheritance
Once a built-in object has
been converted to a new
object, the new object
inherits all the properties
and methods available to
the original object.
truck.load()
where truck is the object and load is a method of the truck object. Methods are followed
by parentheses, which may be empty, or may contain an argument.
An argument is a value given to a method. Some methods require arguments, and
others do not. For example, given a truck object and the load() method, the argument
“firewood” describes the material with which the truck may be loaded and would be
written as:
truck.load(“firewood”)
where the argument “firewood” describes the material loaded into the truck.
 
Search WWH ::




Custom Search