Bug Tracker

Modify

Ticket #12592 (closed bug: invalid)

Opened 19 months ago

Last modified 19 months ago

something wrong with $.fn.offset

Reported by: lkilva@… Owned by: lkilva@…
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocking: Blocked by:

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"?

Change History

comment:1 in reply to: ↑ description Changed 19 months ago by lkilva@…

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".

comment:2 Changed 19 months ago by mikesherov

  • Owner set to lkilva@…
  • Status changed from new to pending

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.

comment:3 Changed 19 months ago by trac-o-bot

  • Status changed from pending to closed
  • Resolution set to invalid

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!

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.