Richard Cornford wrote:
Object inference is an invalid strategy because it is based
on invalid assumptions (that are more often than not actually untrue
in reality).
I've been working on a generalized (cross-browser) way of find the absolute
coordinates of an object on the page. There are a lot of quirks with
different browsers and CSS/positioning, and I've found no positioning script
so far that correctly considers objects with overflow:scroll when
calculating screen position (among other things). I've found that in order
to be accurate in as many browsers as possible, I need to use
feature/objection detection and infer other things based on that.
For example, looking for window.opera or document.compat Mode and inferring
different quirks about how object positions are calculated. Opera already
consider's an element's scroll when it has overflow:scroll into the
offsetLeft/offsetTop values, while other browsers do not. So for other
browsers, you need to consider the scrollLeft/scrollTop values, while for
Opera you do not. I know of no way to "detect" this behavior other than
knowing a browser's behavior and attempting to infer that the browser in use
exhibits this behavior by examining its DOM.
Do you have a better idea?
--
Matt Kruse
http://www.JavascriptToolbox.com