Bug Tracker

Opened 11 years ago

Closed 9 years ago

#3367 closed bug (wontfix)

Offset function returns an incorrect value when the concerned element is within a child iframe

Reported by: dezfowler Owned by: brandon
Priority: minor Milestone: 1.3
Component: offset Version: 1.2.6
Keywords: iframe Cc:
Blocked by: Blocking:

Description

If you do something like this...

var myFrame = document.getElementById('myIFrame'); var framedDoc = myFrame.contentWindow.document; var theOffset = $('#someElement', framedDoc).offset();

The value returned is incorrect as it is the offset of the element relative to the contentWindow of the iframe, not the window where jQuery is running. To corrent this, the offset of the iframe element in the parent window must also be added to the offset.

Attached is a patch fixing this issue that I've tested in a few browsers. Just needs a more exhaustive test and commit.

Attachments (1)

offset-bug.patch (1.9 KB) - added by dezfowler 11 years ago.
SVN patch fixing bug

Download all attachments as: .zip

Change History (2)

Changed 11 years ago by dezfowler

Attachment: offset-bug.patch added

SVN patch fixing bug

comment:1 Changed 9 years ago by dmethvin

Resolution: wontfix
Status: newclosed

This kind of complex case seems like it would be better done in a plugin and used only in the cases where someone actually needs it. The amount of code required to fix the problem is very large.

Note: See TracTickets for help on using tickets.