I've found that under some circumstances, some code that I've been using to
find an object's coordinates with respect to the viewport does not behave
correctly.
Is there a function that has been extensively tested under lots of different
page conditions that will return the x,y position of an object?
Things to consider:
1. Full browser support, as much as possible (meaning, works in any browser
where it's possible, not just the latest browsers implementing the latest
features. Ideally, use DOM and standards, but fall back to proprietary
properties if necessary)
2. Any containing element may be scrolled using overflow:auto (most
algorithms do not consider this)
3. absolute and relative positioning
4. css margins, paddings, etc
5. Different doctypes, and returning the correct values given no doctype,
loose, strict, etc
I've got my code working better now, under every condition I actually need
to support (it was failing because of being within a DIV with
overflow:auto). But I'd really like to have a more robust function, and
rather than do all the testing myself, I was hoping there was an accepted
standard function that was written and/or tested by several 'experts'. It
would certainly save me time ;)
Thanks,
--
Matt Kruse
Javascript Toolbox: http://www.JavascriptToolbox.com/
find an object's coordinates with respect to the viewport does not behave
correctly.
Is there a function that has been extensively tested under lots of different
page conditions that will return the x,y position of an object?
Things to consider:
1. Full browser support, as much as possible (meaning, works in any browser
where it's possible, not just the latest browsers implementing the latest
features. Ideally, use DOM and standards, but fall back to proprietary
properties if necessary)
2. Any containing element may be scrolled using overflow:auto (most
algorithms do not consider this)
3. absolute and relative positioning
4. css margins, paddings, etc
5. Different doctypes, and returning the correct values given no doctype,
loose, strict, etc
I've got my code working better now, under every condition I actually need
to support (it was failing because of being within a DIV with
overflow:auto). But I'd really like to have a more robust function, and
rather than do all the testing myself, I was hoping there was an accepted
standard function that was written and/or tested by several 'experts'. It
would certainly save me time ;)
Thanks,
--
Matt Kruse
Javascript Toolbox: http://www.JavascriptToolbox.com/
Comment