Positioning using DHTML and the XHTML doctype.
by "Mike Taylor" <lonewolf(at)one.net>
|
| Date: |
Tue, 22 Apr 2003 22:20:42 -0400 |
| To: |
<hwg-techniques(at)hwg.org> |
| |
todo: View
Thread,
Original
|
|
I'm trying to manipulate an element called onmouseover within an anchor,
without using the non-standard offsetParent, offsetLeft and offsetTop that
works in only IE and Netscape 6+.
There's a function floating about that helps one determine the position from
which the function was called, creating an array for the x and y coordinates
measured in pixels. This is useful for using, for example, drop-down menus
that appear when you mouse over an element.
Problem is, this function only works if you REMOVE the XHTML DOCTYPE...it
does not appear to be a W3C-DOM standard.
I've found it difficult tracking down a useful alternative. Any suggestions
on a way to find the x and y coordinates without giving up the DOCTYPE
declaration?
Here's the function that is not standard:
function findPosition( oLink ) {
if( oLink.offsetParent ) {
for( var posX = 0, posY = 0; oLink.offsetParent; oLink =
oLink.offsetParent ) {
posX += oLink.offsetLeft;
posY += oLink.offsetTop;
}
return [ posX, posY ];
} else {
return [ oLink.x, oLink.y ];
}
}Thanks,Mike
HWG hwg-techniques mailing list archives,
maintained by Webmasters @ IWA
This page is part of a preserved archive of archives.hwg.org. The site is no longer active and its content is not maintained. For enquiries about this archive, write to archive(at)iwanet.org.