if ( "getBoundingClientRect" in document.documentElement ) {
jQuery.fn.offset = function( options ) {
- var elem = this[0];
+ var elem = this[0], box;
if ( options ) {
return this.each(function( i ) {
return jQuery.offset.bodyOffset( elem );
}
- var box = elem.getBoundingClientRect(),
- doc = elem.ownerDocument,
+ try {
+ box = elem.getBoundingClientRect();
+
+ } catch(e) {
+ return { top: 0, left: 0 };
+ }
+
+ var doc = elem.ownerDocument,
body = doc.body,
docElem = doc.documentElement,
win = getWindow(doc),