Skip to main content

Bug Tracker

Side navigation

#12592 closed bug (invalid)

Opened September 22, 2012 09:08AM UTC

Closed October 08, 2012 09:16AM UTC

something wrong with $.fn.offset

Reported by: lkilva@gmail.com Owned by: lkilva@gmail.com
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:
Description

write a test page:

<!DOCTYPE html>
<html style="border:solid black 2px;margin:1px;padding:4px">
  <head>
	<meta charset="utf-8">
	<script src="jquery-1.8.0.js"></script>
	<script>
    $(function() {
        var a="";
        for(var i=0;i<100;i+=1) a+="aa<br>";
        $("div").html(a);
        var div = $("div")[0],
            doc = div.ownerDocument.documentElement,
            body = div.ownerDocument.body;
		window.div = div;
		window.doc = doc;
		window.body = body;
	})
	</script>
  </head>
  <body style="border:solid red 16px;margin:8px;padding:32px">
    <div id="only" style = "border:solid blue 128px;margin:64px;padding:256px">
    </div>
  </body>
</html>​

$(div).offset().top == 125, the distance from the outerline of the margin of <html> element to the outline of the border of the <div> element, minus the height of the border of <html> element.

set $(doc).css("border","");

$(div).offset().top == 109, the distance from the outline of the margin of <html> element to the outline of the border of the <div> element, minus the height of the border of "<body>" element.

set back $(doc).css("border","solid black 2px")

$(body).offset().top == 8, the distance from "the innerline of the padding of <html> element" to the outline of the border of the <div> element, minus "nothing".

What is the meaning of "relative to the document"?

Attachments (0)
Change History (3)

Changed September 22, 2012 09:35AM UTC by lkilva@gmail.com comment:1

The above is tested in Chrome.

In firefox,

$(div).offset().top == 111, the distance from the outerline of the margin of <html> element to the outerline of the "margin" of the <div> element, minus the height of the border of "<body>" element.

$(body).offset().top === -8, the distance from the innerline of the padding of the <html> element to the outline of the border of the <body> element, minus "the height of the border of <body> element".

Changed September 23, 2012 03:17PM UTC by mikesherov comment:2

owner: → lkilva@gmail.com
status: newpending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/. Open the link and click to "Fork" (in the top menu) to get started.

Changed October 08, 2012 09:16AM UTC by trac-o-bot comment:3

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!