1

I'm currently building something that has to work in Firefox 2 as well as modern browsers. I'm using .offset() to get the coords for the position of various elements on the page and it works fine all browsers except Firefox 2 which returns (0,0) for all elements.

Here's an example.

<!DOCTYPE html>
<html>
<head>

<script type="text/javascript" src="jquery-1.8.3.min.js"></script>

<style>

#page
{
    width:200px;
    background:#ff0000;
    margin:210px auto;
    padding:30px;
}

</style>

<script type="text/javascript">

$(document).ready(function () {
    var offset = $('#page').offset();
    alert('x = ' + offset.left + '\n' + 'y = ' + offset.top);
});

</script>

</head>
<body>

<div id="page">
hello
</div>

Is this a bug in jQuery or should I create some kind of workaround?

Thanks

Russell

4

0 回答 0