I posted this on another thread, but it may apply here, as well:
---
Hi, all. I patched the dropdown.js script to handle the case where one of the ancestor elements is relatively positioned. In this case, the absolute positioning of the menu is relative to that "containing block" and the offset calculation should end there.
Here is the modified function (getposOffset), with an nested function to handle IE, Safari, and Firefox:
Code:
getposOffset:function(what, offsettype){
function getStyle(el,styleProp) {
if (typeof el.currentStyle != "undefined") {
var y = el.currentStyle[styleProp];
} else if (typeof document.defaultView != "undefined" && typeof document.defaultView.getComputedStyle != "undefined") {
var y = document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProp);
} else {
var y = el.style[styleProp];
}
return y;
}
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null && getStyle(parentEl, "position") != "relative"){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
},
Bookmarks