Skip to main content

Bug Tracker

Side navigation

#6949 closed bug (invalid)

Opened August 26, 2010 08:55AM UTC

Closed October 02, 2010 01:45AM UTC

Last modified July 25, 2013 11:37PM UTC

.offset() in IE changes position from absolute to relative

Reported by: cimiak Owned by:
Priority: undecided Milestone: 1.4.3
Component: offset Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

Set the current coordinates using .offset(). If the element's position style property is currently absolute, it is set to relative in IE8. It remains absolute in Firefox as expected.

Attachments (0)
Change History (3)

Changed October 02, 2010 01:45AM UTC by addyosmani comment:1

need: ReviewTest Case
priority: → undecided
resolution: → invalid
status: newclosed

Having tested the bug reported in this ticket in both FireFox 3.6.10, IE 8.0 and IE 9.0, I've noted that jQuery is outputting the same relative positioning regardless of the browser being tested in.

As this behaviour is consistent and suggests the original ticket may not be a genuine issue with the core, please re-submit your ticket including the version of FireFox where offset() was outputting absolute positioning so we can test further.

If you could also include a valid test case/code example of what you're trying to do (if other than just using .offset()) that too would be of help.

Closing for now.

Changed March 08, 2011 03:20PM UTC by kellyselden comment:2

_comment0: i have a test case for this issue. http://jsfiddle.net/qdLrq/ \ \ in firefox, the div will retain its absolute positioning, but in IE, it will be set to relative. the code that does this is at line 8119 in jquery 1.5.1. \ \ {{{ \ // set position first, in-case top/left are set even on static elem \ if ( position === "static" ) { \ elem.style.position = "relative"; \ } \ }}} \ \ it appears that it only happens when you set the offset before you add it to the page in IE.1299598055790898

i have a test case for this issue. http://jsfiddle.net/qdLrq/

in firefox, the div will retain its absolute positioning, but in IE, it will be set to relative. the code that does this is at line 8119 in jquery 1.5.1.

// set position first, in-case top/left are set even on static elem
if ( position === "static" ) {
    elem.style.position = "relative";
}

it appears that it only happens when you set the offset before you add it to the page in IE.

here's a work-around for anyone that wants it:

//v1.offset(v2.offset());
v1.css('left', v2.offset().left).css('top', v2.offset().top);

Changed July 25, 2013 11:37PM UTC by andrew@ajmccluskey.com comment:3

This issue just hit me in jQuery 1.9.1 and the workaround solved my issue. Not sure why this bug is invalid as it is unexpected behaviour that is inconsistent across browsers.