jQuery: The Write Less, Do More JavaScript Library

Ticket #2082 (closed bug: fixed)

Opened 5 months ago

Last modified 4 months ago

Offset function returns wrong value with IE7/position fixed

Reported by: dprunier Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.2.2 Component: core
Version: 1.2.1 Keywords:
Cc: Needs: Review

Description

When querying the offset top of a fixed div in IE7, the scroll is mistakenly counted in the returned value.

Example:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>Test</title>
		<script type="text/javascript" src="js/jquery.js" ></script>
		<script type="text/javascript">
		$(document).ready(function() {
			setInterval(function() {
				$('#fixed').text($('#fixed').offset().top);
			}, 100);
		});
		</script>
	</head>
	<body>
		<div id="fixed" style="position: fixed;
		                       top: 0px; left: 0px;
		                       width: 100px; height: 100px;
		                       background-color: fuchsia;">
		</div>
		<div id="big" style="height: 5000px">
		</div>
	</body>
</html>

Attachments

Change History

Changed 5 months ago by brandon

  • status changed from new to closed
  • resolution set to fixed

This is fixed in the latest SVN.

Changed 4 months ago by dprunier

  • status changed from closed to reopened
  • resolution deleted

The test sample in the description still doesn't work. This is actually broken in both IE7 and FF now (1.2.2, r4454).

Changed 4 months ago by brandon

  • status changed from reopened to closed
  • resolution set to fixed

This is fixed. Please see the modified test case that places a div at the elements location here: http://brandonaaron.net/jquery/tickets/2082/test.html

If the scroll offset is not included then the marker div will not be placed correctly.

This was fixed for all supported browsers in 1.2.2. There is also now an offset test suite that can be found in test/offset.html

Note: See TracTickets for help on using tickets.