Logo
doctype [?]
[strict] [loose] [none]

Object Position and Size


Class Methods

Position.get (object) : Object

Get the top and left position of an object on the page, relative to the root element (HTML or BODY) tag. This can then be used to position another object relative to the first.

ArgumentTypeRequiredDescription
objectObject or StringyesAn object whose position should be calculated. This can be either a reference to the object itself, or a string which will be resolved as an element ID or using document.all or anchor name.

Returns: Object with properties: 'left' and 'top' to specify position, and 'width' and 'height' to specify the dimensions of the object's full box (including padding and borders)


Position.getCenter (object) : Object

Similar to Position.get(), but this method returns the coordinates of the center of the object, rather than the upper left corner.

ArgumentTypeRequiredDescription
objectObject or StringyesAn object whose position should be calculated. This can be either a reference to the object itself, or a string which will be resolved as an element ID or using document.all or anchor name.

Returns: Object with properties: 'left' and 'top' to specify position, and 'width' and 'height' to specify the dimensions of the object's full box (including padding and borders)


Position.set (object, left, top) : Boolean

Set the position of an object to a certain location on the screen. If the object is not already position:absolute, it will be made so in order to be moved. Returns true if successful, else false.

ArgumentTypeRequiredDescription
objectObject or StringyesAn object whose position should be set. This can be either a reference to the object itself, or a string which will be resolved as an element ID or using document.all or anchor name.
leftObject or NumberyesIf passed an Object as the second parameter, the method assumes that this object will contain 'left' and 'top' properties and use those coordinates. If a Number is passed, it is the number of pixels from the left side of the screen to position the object.
topNumbernoIf left is a Number, then top should also be a number, specifying the number of pixels from the top of the screen to position the object.

Returns: Boolean