[Javascript] DOCTYPE making div.style.top NOT WORK
Michael Borchers
list at tridemail.de
Tue Jan 2 01:50:09 CST 2007
----- Original Message -----
From: "Nick Fitzsimons" <nick at nickfitz.co.uk>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Friday, December 22, 2006 6:01 PM
Subject: Re: [Javascript] DOCTYPE making div.style.top NOT WORK
> Try this:
>
> function getPosition(element) {
> var position = {x: 0, y: 0};
> while (element) {
> position.x += element.offsetLeft;
> position.y += element.offsetTop;
> element = element.offsetParent;
> }
> return position;
> }
>
> which will (as with your existing script) return an object with "x"
> and "y" properties, and works (in my quick tests) on IE, Firefox,
> Opera and Safari, even with a DOCTYPE declaration.
works fine! great! thanks!
More information about the Javascript
mailing list