View Full Version : Chrome Drop down and safari issues

12-01-2006, 05:43 PM
1) Script Title: Chrome Drop down menu 2.01

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

3) Describe problem:

Everything great on every thing I try on the pc (ff, ie6, konqueror). Unfortunately, the guy I've done the site for is on a mac (safari) and the drop down appears about 5mm below and to the left of the bar. I don't have a mac myself and have no idea what's wrong with it...the script that is - there's plenty of things wrong with a mac ;)

I've tried swift the safari emulator but that seems to be happy too.

Anyone got any advice...please...


Many thanks.


PS I'm fairly new to css so it's all a bit of a mess. The problem I had was when I decided to center everything so I then couldn't really use absolute values. I eventually found I could only get it to work reasonably if I put it all in a big single-celled centered table.

07-03-2007, 08:46 PM
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:

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;
return totaloffset;