Invalid Domain

You are here :

JavaScript Code Library
dhtml
WM_position2element
by Taylor

This action positions one DHTML element a specified number of pixels away from another, based on the left, top, right, or bottom of the bounding box of each element. To use it, you must choose the element to position and the element to position against; you must specify which side of each element's bounding box to base the positioning on; and you must supply the number of pixels difference between the two. Optionally, you can choose the browser window as the element to position against by using the string window.

You can specify either a positive or a negative integer for the difference between the two elements. You can also mismatch sides (which can create some interesting effects).

Usage: WM_position2element('elementPositioned', 'left|top|right|bottom', differenceInPixels, 'elementPositionedAgainst|window', 'left|top|right|bottom');

Usage notes:

  • All arguments must be strings, with the exception of differenceInPixels, which should be a number.
  • You must set width and height for elementPositioned and elementPositionedAgainst.

Requires: WM_checkIn()

Cut, paste, and enjoy!

SUBMISSIONS
If you have code to share with other Webmonkeys, send it our way.

Can't find something?
Check out the
JavaScript archive