Exforsys

JavaScript Tutorial

  1. JavaScript Browser Objects Part 2
  2. JavaScript Frame object
  3. JavaScript Form Object
  4. JavaScript FileUpload Object
  5. JavaScript Event Object Properties and Methods
  6. JavaScript Event Object
  7. JavaScript Elements and Embed Objects
  8. JavaScript Applet Objects
  9. JavaScript Browser Objects
  10. JavaScript Object Oriented Features
  11. JavaScript Window Object Open Method Part 2
  12. JavaScript Window Object Open Method
  13. JavaScript Window Object Timeout Methods
  14. JavaScript Location Object
  15. JavaScript Location Object Properties
  16. JavaScript History Object Properties and Methods
  17. JavaScript Document Object Methods Part II
  18. JavaScript Document Object Methods Part I
  19. JavaScript Document Object Properties
  20. JavaScript Document Object
  21. JavaScript Windows Object Properties Part II
  22. JavaScript Windows Object Properties Part I
  23. JavaScript DOM Window Object
  24. Working with JavaScript DOM Objects
  25. JavaScript Array Object Methods – Part II
  26. JavaScript Array Object
  27. JavaScript Array Object Methods – Part I
  28. JavaScript Boolean Object
  29. JavaScript OnError Event
  30. JavaScript Exception Handling – Part II
  31. JavaScript Exception Handling – Part I
  32. JavaScript Event Handler
  33. JavaScript Events Handling
  34. JavaScript Array Operations
  35. JavaScript Two Dimensional Arrays
  36. Passing values to JavaScript Function
  37. JavaScript Functions
  38. JavaScript Arrays
  39. JavaScript Iterative Structures - Part II
  40. JavaScript Iterative Structures - Part I
  41. JavaScript Math Object
  42. JavaScript Date Object
  43. JavaScript String Object
  44. JavaScript Objects
  45. JavaScript Confirm Box
  46. JavaScript Alert Box
  47. JavaScript Conditional Statements Part 2
  48. JavaScript Conditional Statements Part 1
  49. How to use JavaScript in HTML page
  50. JavaScript Variables
  51. JavaScript Features
  52. JavaScript Introduction

Ads


Home arrow Technical Training arrow JavaScript Tutorial

JavaScript Frame object

Author : Exforsys Inc.     Published on: 20th May 2007

JavaScript Frame Object

In this JavaScript tutorial, you will learn about frame object its properties and methods in detail with example. frame object, properties of frame object, frames, self, name, length, parent, methods of frame object, blur(), focus(), setInterval(), clearInterval(), setTimeout(expression, milliseconds), clearTimeout() and events associated with frame object.

Ads

Frame Object:

The frame object is a browser object of JavaScript used for accessing HTML frames. The user can use frames array to access all frames within a window. Using the indexing concept, users can access the frames array.

NOTE:

  • 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 properties and methods of frame object are similar to that of Window object in JavaScript.

  • 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:

  • frames
  • name
  • length
  • parent
  • self

frames:

The frames property of frame object denotes a collection or array of frames in a window and also in a frame set.

self:

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.

name:

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:


exforsys=window.frames(2).name

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.

length:

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.

parent:

As the name implies, the parent property of frames object denotes the parent frame of the current frame.

Methods of frame object:

  • blur()
  • focus()
  • setInterval()
  • clearInterval()
  • setTimeout(expression, milliseconds)
  • clearTimeout(timeout)

blur():

blur() method of frame object removes focus from the object.

focus():

focus() method of frame object gives focus to the object.

setInterval():

setInterval() method of frame object is used to call a function of JavaScript or to evaluate an expression after the time interval specified in arguments has expired. The time interval in arguments is always specified in milliseconds.

For example:


setInterval=exforsys(test(),2000)

In the above statement, the function test() executes after 2000 milliseconds (2 seconds), specified in the argument.

clearInterval():

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:


clearInterval (Interval_ID)

setTimeout(expression, milliseconds):

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:


setTimeout(expression, milliseconds)

For example:


exforsys=setTimeout ("test()", 3000)

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():

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:


clearTimeout ID_of_setTimeout

For example


clearTimeout exforsys

Ads

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:

  • onBlur
  • onFocus
  • OnLoad
  • OnUnLoad


 
This tutorial is part of a JavaScript Tutorial tutorial series. Read it from the beginning and learn yourself.

JavaScript Tutorial

  1. JavaScript Browser Objects Part 2
  2. JavaScript Frame object
  3. JavaScript Form Object
  4. JavaScript FileUpload Object
  5. JavaScript Event Object Properties and Methods
  6. JavaScript Event Object
  7. JavaScript Elements and Embed Objects
  8. JavaScript Applet Objects
  9. JavaScript Browser Objects
  10. JavaScript Object Oriented Features
  11. JavaScript Window Object Open Method Part 2
  12. JavaScript Window Object Open Method
  13. JavaScript Window Object Timeout Methods
  14. JavaScript Location Object
  15. JavaScript Location Object Properties
  16. JavaScript History Object Properties and Methods
  17. JavaScript Document Object Methods Part II
  18. JavaScript Document Object Methods Part I
  19. JavaScript Document Object Properties
  20. JavaScript Document Object
  21. JavaScript Windows Object Properties Part II
  22. JavaScript Windows Object Properties Part I
  23. JavaScript DOM Window Object
  24. Working with JavaScript DOM Objects
  25. JavaScript Array Object Methods – Part II
  26. JavaScript Array Object
  27. JavaScript Array Object Methods – Part I
  28. JavaScript Boolean Object
  29. JavaScript OnError Event
  30. JavaScript Exception Handling – Part II
  31. JavaScript Exception Handling – Part I
  32. JavaScript Event Handler
  33. JavaScript Events Handling
  34. JavaScript Array Operations
  35. JavaScript Two Dimensional Arrays
  36. Passing values to JavaScript Function
  37. JavaScript Functions
  38. JavaScript Arrays
  39. JavaScript Iterative Structures - Part II
  40. JavaScript Iterative Structures - Part I
  41. JavaScript Math Object
  42. JavaScript Date Object
  43. JavaScript String Object
  44. JavaScript Objects
  45. JavaScript Confirm Box
  46. JavaScript Alert Box
  47. JavaScript Conditional Statements Part 2
  48. JavaScript Conditional Statements Part 1
  49. How to use JavaScript in HTML page
  50. JavaScript Variables
  51. JavaScript Features
  52. JavaScript Introduction
 

Comments