JavaScript (obtain or set the width, height, and coordinates of HTML elements)
Settings:
Document. getelementbyid ('id'). style. width = Value
Document. getelementbyid ('id'). style. Height = Value
Document. getelementbyid ('id'). style. Top = Value
Document. getelementbyid ('id'). style. Left = Value
Obtain:
Value = Document. getelementbyid ('id'). offsetleft
Value = Document. getelementbyid ('id'). offsettop
Value = Document. getelementbyid ('id'). offsetwidth
Value = Document. getelementbyid ('id'). offsetheight
Find the coordinates of an element:
function findPosition( oElement ){ var x2 = 0; var y2 = 0; var width = oElement.offsetWidth; var height = oElement.offsetHeight; alert(width + "=" + height); if( typeof( oElement.offsetParent ) != 'undefined' ) { for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) { posX += oElement.offsetLeft; posY += oElement.offsetTop; } x2 = posX + width; y2 = posY + height; return [ posX, posY ,x2, y2]; } else{ x2 = oElement.x + width; y2 = oElement.y + height; return [ oElement.x, oElement.y, x2, y2]; }}