[thelist] Quick JS question - x and y position of an image

Peter-Paul Koch gassinaumasis at hotmail.com
Fri Jan 24 01:40:01 CST 2003

>In Javascript, how can I find the x and y position of an image in a
>document? I want to do this so that I can have a floating layer appear
>it as a rollover action, i.e. something like
>	var myLayer = document.getElementById('my_layer');
>	myLayer.style.left = x_coordinate_of_image;
>	myLayer.style.top = y_coordinate_of_image + 50;
>	myLayer.style.visibility = "visible";
>It looks like I can use offsetHeight and offsetLeft to do what I want in
>Internet Explorer, but how do I do it in Netscape?

See http://www.xs4all.nl/~ppk/js/index.html?findpos.html

ppk, freelance web developer
Interaction, copywriting, JavaScript, integration
Column "Keep it Simple": http://www.digital-web.com/columns/keepitsimple/
W3C DOM Compatibility Table, expanded & updated

The new MSN 8: advanced junk mail protection and 2 months FREE*

More information about the thelist mailing list