The Design of Software (CLOSED)A public forum for discussing the design of software, from the user interface to the code architecture. Now closed. |
||
|
The "Design of Software" discussion group has been merged with the main
Joel on Software discussion group.
The archives will remain online indefinitely. |
O' javascript gurus, help the hapless!
I have a simple need - I need to display an icon on an image at a specific coordinate. IE 6 is enough. So I have an image, and a hidden DIV with the necessary background. The image is an ASP.NET image button (therefore an input type="image" and not actually an IMG) My javascript function takes the image-relative position (i.e. as you would do in a hotspot) but to put the box I need the coordinate adjusted factoring the position of the image itself. The function is this: function GetRealTopAndLeft(img,left,top) { var mleft = (img.offsetLeft + left); varm mtop = (img.offsetTop + top); var tmp = img; if(!tmp) { alert("image def is null!"); } while (tmp.offsetParent) { tmp = tmp.offsetParent; if(!tmp) { alert("no tmp!"); } mleft+=tmp.offsetLeft; mtop+=tmp.offsetTop; } return [mleft,mtop] This USED to work - i don't know what I changed, can't find anything - but while it works flawlessly in firefox it just doesn't work in IE, I get 0 for everything.. it does loop thru the while, so I know it's getting the parent objects, but the darned things get 0 for all offsetLeft/Top. What am I doing wrong?!
The code you posted has so many bugs in it it's hard to follow.
Post soemthing that has a chance of working...
TomH Friday, May 13, 2005 |
|
Powered by FogBugz


