Ticket #1651 (closed bug: fixed)
obscure offset bug in IE
|Reported by:||wizzud||Owned by:|
The inclusion of an HTML element with an id of 'box' causes IE to fail in the offset method, reporting that "Object doesn't support this property or method" and relating to elem.getBoundingClientRect(). This is even though it has just passed a logic test for it!
The solution is to declare box locally, ie change
box = elem.getBoundingClientRect();
var box = elem.getBoundingClientRect();
The problem and solution can be seen demonstrated at http://www.wizzud.com/tester/offset_quirks.html or http://www.wizzud.com/tester/offset_standard.html (quirks mode or standard mode respectively). Click 'fix #box bug' to run fixed code.
The demo is set up such that offset is called on the #box element itself, but it will still fail if #box exists anywhere on the page and offset() is called on any other element.