The frames array index always starts with zero and not 1.
The frame object is actually a child of the window object. These objects are created automatically by the browser and help users to control loading and accessing of frames.
The frame object does not support close() method that is supported by window object.
Using the <FRAMESET> document creates frame objects and each frame created is thus a property of window object.
Properties of frame object:
The frames property of frame object denotes a collection or array of frames in a window and also in a frame set.
As the name implies, the self property of frames object denotes the current frame. Using self property, the user can access properties of the current frame window.
The name property of frame object denotes the name of the frame. The method of denoting the name attribute is performed by using the name attribute of the <frame> tag.
For example it can be written as:
The above statement would store the name of the third window frame (as the frames array start with index 0) in a frameset document in the variable exforsys.
The frames array has all the frames present within a window and the length property of the frame object denotes the length of the frames array or gives the number of frames present in a window or a frames array.
As the name implies, the parent property of frames object denotes the parent frame of the current frame.
Methods of frame object:
- setTimeout(expression, milliseconds)
blur() method of frame object removes focus from the object.
focus() method of frame object gives focus to the object.
In the above statement, the function test() executes after 2000 milliseconds (2 seconds), specified in the argument.
clearInterval method of frame object is used to cancel the corresponding defined setInterval method. This is written by referencing the setInterval method using its ID or variable.
General syntax for the method clearInterval() is as below:
setTimeout method of frame object can be used to execute any function, or access any method or property after a specified time interval given to this method as argument.
General syntax for the method setTimeout() is as below:
The time is always specified in milliseconds and in the above statement, the function test() is called after the specified time of 3000 milliseconds (3 seconds). This is stored in variable named exforsys.
There is confusion about the similarity between setTimeout() method and setInterval() method. The main difference between the two methods is the setInterval method will repeatedly call the referenced function or evaluate the expression until the user leaves the document. In the setTimeout method, the call executes only once after the specified time interval given as argument.
clearTimeout method of frame object is used to clear a specified setTimeout method. This is written by referencing the setTimeout method using its ID or variable.
General syntax for the method clearTimeout is as below:
The above statement clears the setTimeout associated wit the ID named as exforsys, created in the earlier example.
Events associated with frame object:
Though the frame object and frames array have no event handlers associated directly with them, the following event handlers are used to access and control frame objects and frames array: