getBounds Method
Gets the x and y coordinates, width and height of a element.
getBounds Method is in Sys.UI.DomElement namespace.
Returns a json formatted object with x,y,width,height as its members.
// Example
// Get the bounds of the element
var elementRef = $get("elementID");
var elementBounds = Sys.UI.DomElement.getBounds(elementRef);
var xPosition = elementBounds.x;
var yPosition = elementBounds.y;
var width = elementBounds.width;
var height = elementBounds.height;
getLocation Method
Gets the x and y coordinates.
getLocation Method is in Sys.UI.DomElement namespace.
Returns a json formatted object with x,y,width,height as its members.
getLocation may fail to return a correct value if the positing is fixed mode.(style="position:fixed").
// Example
// Get the bounds of the element
var elementRef = $get("elementID");
var elementBounds = Sys.UI.DomElement.getLocation(elementRef);
var xPosition = elementBounds.x;
var yPosition = elementBounds.y;
setLocation Method
Sets the x and y coordinates.
setLocation Method is in Sys.UI.DomElement namespace.
//Example
// Get the location of the element
var elementRef = $get("elementID");
var elementLoc = Sys.UI.DomElement.getLocation(elementRef);
// Move the element's x position
Sys.UI.DomElement.setLocation(elementRef, 100, elementLoc.y);
No comments:
Post a Comment