Hello,
I've got a script to get the XY coordinates of an images. The problem is it's a function, and it will only execute if the user activates the function, right? I want to get the position of the image while the page loads, so I can add a CSS layer(Popup menu) at that position. Is this possible without the use of function? or is it possible to execture the function while loading. I'm not even sure how I would call the function, and how does the function know which image to check? Here is the script:
function getXYcoord ( nvn ) {
var elm = document.images[nvn];
if ( document.layers ) return elm;
// NS4 images contain x and y values
var rd = { x:0 ,y:0 };
do { rd.x += parseInt( elm.offsetLeft );
rd.y += parseInt( elm.offsetTop );
elm = elm.offsetParent;
} while ( elm );
return rd
}; //end getXYcoord ( string ) -> object{x,y}
var pos = getXYcoord( 'imagename' );
alert( "image x,y coords are" +pos.x +"," +pos.y );
I've got a script to get the XY coordinates of an images. The problem is it's a function, and it will only execute if the user activates the function, right? I want to get the position of the image while the page loads, so I can add a CSS layer(Popup menu) at that position. Is this possible without the use of function? or is it possible to execture the function while loading. I'm not even sure how I would call the function, and how does the function know which image to check? Here is the script:
function getXYcoord ( nvn ) {
var elm = document.images[nvn];
if ( document.layers ) return elm;
// NS4 images contain x and y values
var rd = { x:0 ,y:0 };
do { rd.x += parseInt( elm.offsetLeft );
rd.y += parseInt( elm.offsetTop );
elm = elm.offsetParent;
} while ( elm );
return rd
}; //end getXYcoord ( string ) -> object{x,y}
var pos = getXYcoord( 'imagename' );
alert( "image x,y coords are" +pos.x +"," +pos.y );