The following jQuery code works just fine for me with Safari, Opera, FF2, and FF3. It positions a busy DIV (with an animated busy GIF) on top of a FORM element on my web page. The problem is that in IE6 and IE7, it gets width and height properly, but doesn't seem to get top and left properly. What's the catch?
var nH = $('#' + sForm).attr('offsetHeight');
var nW = $('#' + sForm).attr('offsetWidth');
var nT = $('#' + sForm).attr('offsetTop');
var nL = $('#' + sForm).attr('offsetLeft');
$('#busy')
.css('position','absolute')
.css('height', nH + 'px')
.css('width', nW + 'px')
.css('top', nT + 'px')
.css('left', nL + 'px')
.show();
Note that on my page I have multiple FORM elements. (The reason for the busy GIF is because I'm doing an AJAX post in the background when a form is submitted.)
Note I also tried the jQuery Dimensions Plugin 1.2's .position() value for top and left, and that helped, but seemed to have the 'top' value become more off the further I moved down in the page.