diff options
author | brandonaaron <brandon.aaron@gmail.com> | 2010-02-27 19:43:23 -0600 |
---|---|---|
committer | brandonaaron <brandon.aaron@gmail.com> | 2010-02-27 19:43:23 -0600 |
commit | 1d352084c4257217b0778f1ec3bb2e409411a4c3 (patch) | |
tree | 84d688650c18c7b3fd1f5e4f1798b41d03155fd4 /src/offset.js | |
parent | 36faab439a1d3a5471847e952d0019e8e4e9b982 (diff) | |
download | jquery-1d352084c4257217b0778f1ec3bb2e409411a4c3.tar.gz jquery-1d352084c4257217b0778f1ec3bb2e409411a4c3.zip |
Use correct window reference in offset to work properly cross-frame. Fixes #6190.
Diffstat (limited to 'src/offset.js')
-rw-r--r-- | src/offset.js | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/offset.js b/src/offset.js index f80574eea..fbefd7a27 100644 --- a/src/offset.js +++ b/src/offset.js @@ -16,10 +16,17 @@ if ( "getBoundingClientRect" in document.documentElement ) { return jQuery.offset.bodyOffset( elem ); } - var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement, - clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, - top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop, - left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft; + var box = elem.getBoundingClientRect(), + doc = elem.ownerDocument, + body = doc.body, + docElem = doc.documentElement, + win = getWindow(doc), + clientTop = docElem.clientTop || body.clientTop || 0, + clientLeft = docElem.clientLeft || body.clientLeft || 0, + scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ), + scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft), + top = box.top + scrollTop - clientTop, + left = box.left + scrollLeft - clientLeft; return { top: top, left: left }; }; |