1. Home
  2. Computing & Technology
  3. JavaScript

Object Functions

1. Introduction

clr gif
Join the Discussion

Questions? Comments?

More of this Feature

Get the Script Add to Your Script

If you are going to code some dynamic HTML (dHTML) for your web pages then you will probably be moving objects around the screen, resizing objects, and/or making them appear and disappear. You will need a way of determining where the object currently is on the screen, how big it is, and whether it is visible or not. If you want your script to work on as many browsers as possible you will also want to use code that is compatible with all three Document Object Models.

To save you the effort of writing these functions yourself , I am supplying a set of eight functions that will provide this information for you.

Let's take a look at the functions included in this library and the values that they hold at the time this page was first displayed. First, here's an object for us to reference.

test object

I gave the above div an id of "test" so that we can see what the other functions functions return by calling them as follows:

If you are going to be creating dynamic effects using objects then you will need to obtain these functions so that you will know where on the page your objects currently are, how big they are, and whether they are visible.

Explore JavaScript
About.com Special Features

Holiday Central

What to eat, where to go, fun things to do and how to save money on the perfect gifts. More >

Family Tech Center

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.