PDA

View Full Version : JS/CSS compatability trouble



blue sam3
04-21-2009, 06:50 PM
I am using a menu bar based on js/css, and it works fine on my computer, in any browser but after complaints, I checked on other computers, and it seems to have issues in all other copies of IE and, strangely, one copy of firefox (although it is rendered slightly differently in Opera, this isn't a real problem).

The menu bar is a fairly simple dropdown and slide one. When the problem occurs, the menus, rather than disappearing when the mouse has been removed from the item, it flashes rapidly, around 4 times per second on the first one, then progressively faster when multiple menus are flashing, until it hits the screen refresh rate. It is also impossible, when the error is present, to open the sliding sub-sub-menus.

Anyone know what could be causing this problem?

Snookerman
04-21-2009, 06:54 PM
Please post a link to the page on your site that contains the problematic script or attach your code so we can check it out and help you.

blue sam3
04-21-2009, 06:59 PM
JS:


var menu=function(){
var t=15,z=50,s=6,a;
function dd(n){this.n=n; this.h=[]; this.c=[]}
dd.prototype.init=function(p,c){
a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
for(i;i<l;i++){
var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
h.onmouseover=new Function(this.n+'.st('+i+',true)');
h.onmouseout=new Function(this.n+'.st('+i+')');
}
}
dd.prototype.st=function(x,f){
var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
clearInterval(c.t); c.style.overflow='hidden';
if(f){
p.className+=' '+a;
if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
if(c.mh==c.offsetHeight){c.style.overflow='visible'}
else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
}
function sl(c,f){
var h=c.offsetHeight;
if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
clearInterval(c.t); return
}
var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
c.style.height=h+(d*f)+'px'
}
return{dd:dd}
}();



CSS:




body {margin:25px; font:11px Verdana,Arial; background:#eee}
ul.menu {list-style:none; margin:0; padding:0}
ul.menu * {margin:0; padding:0}
ul.menu a {display:block; color:#000; text-decoration:none}
ul.menu li {position:relative; float:left; margin-right:2px}
ul.menu ul {position:absolute; top:26px; left:0; background:#d1d1d1; display:none; opacity:0; list-style:none}
ul.menu ul li {position:relative; border:1px solid #aaa; border-top:none; width:104px; margin:0}
ul.menu ul li a {display:block; padding:3px 7px 5px; background-color:#d1d1d1}
ul.menu ul li a:hover {background-color:#c5c5c5}
ul.menu ul ul {left:90px; top:-1px}
ul.menu .menulink {border:1px solid #aaa; padding:5px 7px 7px; font-weight:bold; background:url(images/header.gif); width:80px}
ul.menu .menulink:hover, ul.menu .menuhover {background:url(images/header_over.gif)}
ul.menu .sub {background:#d1d1d1 url(images/arrow.gif) 82px 8px no-repeat}
ul.menu .topline {border-top:1px solid #aaa}



URL:dysailing.com

It is based on a dynamic drive script, I had edited it a lot, but after finding this problem reverted it to the original in an attempt to clear it, which failed.