X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Foffset.js;h=7f654d8f2613d93a929c9aac45301dc4dfffad23;hb=5057ff9f43017f673894584358ca95c8753b65d4;hp=650cc08e9d72fbdf73813209f7915bfbbf75a788;hpb=c8dd49f756562fef68f664869952e4f5aab08acd;p=jquery.git diff --git a/src/offset.js b/src/offset.js index 650cc08..7f654d8 100644 --- a/src/offset.js +++ b/src/offset.js @@ -5,7 +5,7 @@ var rtable = /^t(?:able|d|h)$/i, 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 ) { @@ -21,8 +21,14 @@ if ( "getBoundingClientRect" in document.documentElement ) { return jQuery.offset.bodyOffset( elem ); } - var box = elem.getBoundingClientRect(), - doc = elem.ownerDocument, + try { + box = elem.getBoundingClientRect(); + + } catch(e) { + box = { top: 0, left: 0 }; + } + + var doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, win = getWindow(doc),