View Full Version : Chromemenu within absolute or relative positioned div's

02-16-2010, 02:28 PM
1) Script Title: Chromemenu within absolute or relative positioned div's

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/chrome/index.htm

3) Describe problem:
When putting a chromemenu within an absolute ore relative positioned DIV, the prsition calculation did not work properly so that the menu is popped up on a wrong position. :(

I have made a chang in the positionning function so that the calculation stops when the offset element is absolutely or relatively positioned:

measure: function(el, styleProp) {
var st;
if (el.currentStyle)
st = el.currentStyle[styleProp];
else if (window.getComputedStyle)
st = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
return st;

getposOffset:function(what, offsettype){
var pos;
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
pos=this.measure(parentEl, 'position');
if (pos=='absolute' || pos=='relative') {
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
return totaloffset;

This works fine now. :)