Sunday, June 29, 2008

JS Objects -part 1

Browser Objects and Built-in Objects

JavaScript organizes all the objects in a Web page in a hierarchy. Six built in browser objects are available and they can be used in any scripting language and three built-in objects.

Browser Objects:
Window
Document
Form
Navigator
History
Location
Built-in Objects:
String
Math
Date

Window Object :
The window object is the top level object in the object model. It contains all other objects except the navigator object, which is not tied to any particular window.

Properties:-
default status – The default message in the status bar
frames - An array that describes all the frames in the window
length - Reflects the number of frames in a window
name - Name of the window
status - Values that appear in the window's status bar, usually last for a moment before being overwritten by some other event.
Method:
alert : Bring up alert dialog box in which we can display the data
close : Closes the window
confirm : Bring up a dialog box with yes or no buttons and a user specified
message
open : opens a new window
prompt : Brings up a window with user specified text and an
input box that allows the user to type information

Document Object :
The document object is very useful because it contains a lot of information about the current document.

Properties :
alinkcolor : reflects ALINK attribute of tag
anchors : array listing of all the html anchors
anchor : an anchor object
bgcolor : used to set the background color of document
fgcolor : used to set foreground color (text color) of the document
history : The object containing current browser's history
linecolor : default color setting for all the links
vlinkcolor: used to set the color of the links that have been visited

Methods :
clear ; Clears the window of all its content
close : close the open document
open : opens a new document
write ; writes some expression to current window
writeln : writes some expression to current window and write a new line character at the end
Form Object:

The Form object is created every time Javascript encounters a
.....
in the HTML document. It contains all the information about the form
as well as it can be used to submit information to the server.

Properties:
action : reflects the html action attribute of the
tag
elements : an array of listing of all the elements in a form
length : number of elements in the form
method : reflects METHOD attribute of the tag

Method :
Submit : submits the form to the location in the ACTION attribute


Navigator Object :
This object contains the information about the browser like name of browser,version etc.

Properties :
AppCodeName : The code name of the browser
appName : Name of browser
appVersion : Contains the user – agent header that the server sends to
the server to identify itself
History Object:

This object is used to navigate between pages

Methods:

forward
back
go(n) where n is an integer

Built -in Objects
String object :
String object's method can be used to modify and add HTML modification without changing the string itself. Any number of its methods can be stringed together to create multi-layers of HTML encoding.

Properties:
length : number of characters in the string

Methods:
anchor: converts string to anchor
charAt : returns the character at some index value . Index is read from left to write
fixed : encloses a string in ...
index of ; looks for first instance of some string and returns the index of the first character in the target string
link : converts string to hyperlink
substring : given start and end indices, returns the string contain within those indices
to lowercase : convert to lowercase
touppercase : convert to upper case


Math Object:
The Math object contains a set of methods that are used to perform high level mathematical operations. It has a set of properties and methods. Instance for Math object need not be created.

Properties:
1.E
2.log2E
3.ln2
4.log10E
5.ln10
6.PI
Methods
1.abs
2.acos
3.asin
4.max
5.min
6.sqrt
7.Log
8.Abs
9.Ceil
10.Floor
11.round

Date Object :
The Date object allows gathering information about the client's current time,year, month, and date

Methods:
getDate : returns current date
getDay : returns the day of the week
get Hours : returns number of hours since midnight
getMinutes : returns the number of minutes in past hour
getMonth : number of month since January
getSeconds:
getTime :
getYear:

No comments: