More Info


You are in: home > javascript > javascript api >

JavaScript API

Move Page Element - moveXY()

Move the element "myObject" to screen co-ordinates x, y.

NOTE: All browsers except Opera 5 use the "px" suffix. Otherwise, when the doctype of your document is specified as HTML4.0 in the DOM browsers, the function will not work.

The Code

function moveXY(myObject, x, y) {
	obj = getStyleObject(myObject);
	if (ns4) {
		obj.top = y;
 		obj.left = x;
	} else {
		if (op5) {
			obj.pixelTop = y;
 			obj.pixelLeft = x;
		} else {
			obj.top = y + 'px';
 			obj.left = x + 'px';
		}	
	}
}
<< PREVIOUS PAGE: Get Image Top/Left NEXT PAGE: Change Style Class >>





 © James Austin 2002-05 Web site design by James Austin