Getting left,top positions of an img object... 
Author Message
 Getting left,top positions of an img object...

I am having a lot of trouble with NS6 (IE6/Opera6 are no problem)...

I need to get the top and left position of images in client/page coordinates via jscript for
positioning a div element.

NS6 errors when I try to read any properties of the image object (I have no trouble getting a handle
to the img object).

In IE/Opera I just used the event object to get the position of the image under the mouse cursor.

In NS6 you have to create an 'event' for each object or table row to use the NS6 event object at
all. However, I can only get the mouse position that way, which does not help since the div needs to
be positioned just under the img, flush left.

Any help would be greatly appreciated... TIA

--
Mark E Alsop



Sun, 29 Aug 2004 17:00:49 GMT  
 Getting left,top positions of an img object...


Quote:
> I need to get the top and left position of images in client/page coordinates
via jscript for
> positioning a div element.

http://www.faqts.com/knowledge_base/view.phtml/aid/9095

--
Thor Larholm
<URL: http://www.jibbering.com/faq/> FAQ for comp.lang.javascript



Sun, 29 Aug 2004 20:11:15 GMT  
 Getting left,top positions of an img object...
Thanks for the reply...

I had to play with the sample code you pointed to using NS6 to work out how to use the returned
values, it is not very straight-forward but I think I can make it work.

It appears that there is no way to 'construct' an id string for an image as you can with other
elements. Maybe I'll have to use a span around each image so I can use the getElementById function.

Thanks again...

--
Mark E Alsop



| > I need to get the top and left position of images in client/page coordinates
| via jscript for
| > positioning a div element.
|
| http://www.faqts.com/knowledge_base/view.phtml/aid/9095
|
| --
| Thor Larholm
| <URL: http://www.jibbering.com/faq/> FAQ for comp.lang.javascript
|
|



Mon, 30 Aug 2004 17:03:47 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. style="position:absolute;left;top;"

2. Getting position of a relatively-positioned object

3. fix annotation at the top-left of the page

4. top anf left Div tag style properties not showing as expected

5. How to close a the top frame, but leave the bottom where it's at

6. TOP LEFT corner

7. Retrieving style values (eg left and top)

8. How can I change the Left and top position of a div tag in Navigator 6 ?

9. Getting a window to move on top of other windows

10. img object

11. Just getting the position of an image !

12. Getting offsetX or width for relativ positioned div

 

 
Powered by phpBB® Forum Software