Skip to main content

Bug Tracker

Side navigation

#11542 closed bug (fixed)

Opened April 01, 2012 12:31PM UTC

Closed October 25, 2012 03:43AM UTC

Last modified October 29, 2012 04:44PM UTC

body.offset() is assumed always 0,0

Reported by: atirip Owned by:
Priority: low Milestone: None
Component: offset Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

jQuery assumes that body.offset() is always {0,0}, but this is wrong.

<!DOCTYPE html>
<title> jquery position bug</title>
html {
	background: #3F434C;
	height: 100%;
body {
	width: 100%;
	max-width: 640px;
	min-width: 320px;
	height: 100%;
	margin: 0 auto;
	background: #DDD;
<script src=""></script>
		alert( $('div').position().left );

Expected result for alert is 0 (for windows wider than 640px), but depending on window width, real body.offset.left is returned.

Proposed fix: assume body as normal html element in offset module

Attachments (0)
Change History (5)

Changed April 01, 2012 01:13PM UTC by sindresorhus comment:1

component: unfiledoffset
priority: undecidedlow
status: newopen

Please read the text in the red box and provide a testcase on jsfiddle the next time. Thanks :)

Simplified testcase:

Changed September 17, 2012 05:54PM UTC by gibson042 comment:2

keywords: → 1.9-discuss

Changed October 14, 2012 10:26PM UTC by mikesherov comment:3

+1, I'm weary of people who are fitzing with body, but we should investigate.

Changed October 25, 2012 03:43AM UTC by Daniel Gálvez comment:4

resolution: → fixed
status: openclosed

Fix #11542. document.body should not be special in .offset() and document.documentElement is the default element.offsetParent. Close gh-899.

Changeset: b398a68333d5eb9859fabb1ceabe84a1a753760a

Changed October 29, 2012 04:44PM UTC by dmethvin comment:5

keywords: 1.9-discuss