Hey All, I have a fairly basic question about the prototype.js library. First, I''ve been looking for documentation on this and I have yet to find it. If any of you know of any, please let me know. Since I''m new to both the scriptaculous and prototype libraries could someone explain why I would want to use the cumulativeOffset method and not to just grab the offset off the element I''m working with? Cheers, Marty
> I have a fairly basic question about the prototype.js library. First, > I''ve been looking for documentation on this and I have yet to find it. > If any of you know of any, please let me know. Since I''m new to both > the scriptaculous and prototype libraries could someone explain why I > would want to use the cumulativeOffset method and not to just grab the > offset off the element I''m working with?cumulativeOffset includes the offsets of the element''s parents. Try this: <html> <head> <script src="PATH/TO/prototype.js" type="text/javascript"></script> </head> <body style="margin:0;"> <div style="position:relative;top:50px; left:50px;"> <div id="test" style="position:relative;top:50px; left:50px;">test!</div> </div> <script type="text/javascript"> document.write("offsetLeft of test is: " + $(''test'').offsetLeft + "<br />"); document.write("left cumulativeOffset of test is: " + Position.cumulativeOffset($(''test''))[0]); </script> </body> </html> -- Michael Daines http://www.mdaines.com
Michael Daines wrote:>> I have a fairly basic question about the prototype.js library. >> First, I''ve been looking for documentation on this and I have yet to >> find it. If any of you know of any, please let me know. Since I''m >> new to both the scriptaculous and prototype libraries could someone >> explain why I would want to use the cumulativeOffset method and not >> to just grab the offset off the element I''m working with? > > > cumulativeOffset includes the offsets of the element''s parents. > >Ah, that makes sense if calling an element''s offset only gets its relative offset to its parent. Thanks! Cheers, Marty