Skip to main content

Bug Tracker

Side navigation

#3367 closed bug (wontfix)

Opened September 12, 2008 05:17PM UTC

Closed November 13, 2010 08:06PM UTC

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 September 12, 2008 05:18PM UTC.

    SVN patch fixing bug

Change History (1)

Changed November 13, 2010 08:06PM UTC by dmethvin comment:1

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.