Aiutone JavaScript

Pubblicità

castrecchia

Nuovo Utente
Messaggi
1
Reazioni
0
Punteggio
24
Hi!

vorrei chiedere se qualcuno è abbastanza abile da risolvermi un paio di rompicapi..

Sto facendo un menu a tendina, l'ho scritto praticamente tutto, aggiungendo pezzo a pezzo, e rivisitandolo più volte per abbellirlo, ma sono arrivato ad un certo punto che alcune funzioni.. non funzionavano più, e ora non riesco a capire cosa ci sia che non va...
Codice:
<html>
<head>
<title>Menu Tendina</title>
<style type="text/css">
<!--
body {
    background-color: #333333;
}
.style2 {font-family: Arial, Helvetica, sans-serif}
-->
</style></head>
<body leftmargin="0" topmargin="7">
<table width="133%" height="70" border="0">
  <tr>
    <td width="100%" height="40" bgcolor="#202020" scope="col"><div align="center"><img src="http://www.../header.png" width="351" height="66" hspace="50" align="left" /></div></td>
  </tr>
</table>
<p style="font-family:Arial, Helvetica, sans-serif" style="font-size:6px" >
<script language="JavaScript" type="text/javascript">
<!--
var ron="IMG/bar_c.png"; // Colore al MouseOver, se si cambia, cambiare anche dopo per il blinker!
var roff="IMG/bar_h.png"; // Colore di default, se si cambia, cambiare anche dopo per il blinker!
var imgs="IMG/bar_sd.png";
var ctopb="#555555"; // Colore Head
var ctopf="#ffffff";
var leftmargin=eval(screen.width/2 - 330); // Distanza dal margine sinistro della pagina
var topmargin=95; // Distanza dal margine superiore della pagina
var largo=220; // Larghezza dei layer
var voci=new Array();
    voci[0]=new Array("Blog","due","tre","quattro","cinque","sei")
    voci[1]=new Array("Download","due","tre","quattro","cinque","sei");
    voci[2]=new Array("Social Links","add on Facebook","follow on Twitter","add on MySpace","watch video on Vimeo","view my pic on Flickr");
var links=new Array();
    links[0]=new Array("","#","#","#","#","#")
    links[1]=new Array("","#","#","#","#","#")
    links[2]=new Array("","#","#","#","#","#")
var wst=new Array();
    wst[0]=new Array("1","2","3","4","5","6");
    wst[1]=new Array("1","2","3","4","5","6");
    wst[2]=new Array("1","2","3","4","5","6");
var nn=document.layers?true:false,conta=0,last=0;
document.write("<img src="+imgs+" hspace="+eval(screen.width/2 -330-16)+">");
if (nn)
    {
//    document.write("<LAYER NAME=mtop. position=absolute left="+leftmargin+" top="+topmargin+" width=50 height=15 clip=0,0,50,15 bgColor="+roff+" visibility=visible onMouseOver=showdeps(last,false); mroll('mtop.') onMouseOut=unmroll('mtop.')>;<A HREF='home.html' CLASS=menuNNb>Home</A></LAYER>");
    for (i=0;i<voci.length;i++)
        {
        var n=i;
        document.writeln("<LAYER NAME=mtop"+n+". position=absolute left="+eval(leftmargin+50+largo*i)+" top="+topmargin+" width="+largo+" height=15 clip=0,0,"+largo+",15 bgColor="+ctopb+" fgColor="+ctopf+" visibility=visible onMouseOver=MostraMenu("+i+");mroll('mtop"+i+".');conta++ onMouseOut=last="+i+";unmroll('mtop"+i+".');conta--><DIV ALIGN=center>&nbsp;<A HREF=javascript:mroll('mtop"+i+".') CLASS=menuNNb>"+voci[i][0]+"</A></DIV></LAYER>");
    for (l=1;l<voci[i].length;l++)
        document.writeln("<LAYER NAME=mdep"+i+"."+l+" position=absolute left="+eval(leftmargin+50+largo*i)+" top="+eval(topmargin+15*l)+" width="+largo+" height=15 clip=0,0,"+largo+",15 bgColor="+roff+" visibility=hidden onMouseOver=mroll('mdep"+n+"."+l+"');conta++ onMouseOut=unmroll('mdep"+n+"."+l+"');conta-->&nbsp;<A HREF=javascript:mroll('mdep"+n+"."+l+"') onClick=vai('"+links[i][l]+"',"+i+","+l+") CLASS=menuNN>"+voci[i][l]+"</A></LAYER>");
        }
    }
else
    {
//    document.write("<DIV ID=mtop. STYLE=\"position:absolute; left:"+leftmargin+";top:"+topmargin+";width:50;height:15;background:"+roff+";visibility:visible;cursor:hand\" onMouseOver=showdeps(last,false);mroll('mtop.') onMouseOut=unmroll('mtop.')><A HREF='home.html' CLASS=menuIEb onFocus=this.blur()>&nbsp;<I>Home</I></A></DIV>");
    for (i=0;i<voci.length;i++)
        {
        var n=i;
        document.writeln("<DIV ID=mtop"+n+". STYLE=\"position:absolute;left:"+eval(leftmargin+largo*i)+";top:"+topmargin+";width:"+eval(largo)+";height:25;foreground:"+ctopf+";background:"+ctopb+";visibility:visible;cursor:arrow\" onMouseOver=MostraMenu("+n+");conta++ onMouseOut=last="+n+";conta--><DIV ALIGN=center CLASS=menuIEb>&nbsp;"+voci[i][0]+"</DIV></DIV>"); // <- per modificare le impostazioni del primo della lista
    for (l=1;l<voci[i].length;l++)
        document.writeln("<DIV ID=mdep"+i+"."+l+" STYLE=\"position:absolute;left:"+eval(leftmargin+largo*i)+";top:"+eval(topmargin+26*l)+";width:"+eval(largo-0)+";height:25;background-image:url('"+roff+"');visibility:hidden;cursor:hand\" onMouseOver=;mroll('mdep"+n+"."+l+"');conta++ onMouseOut=unmroll('mdep"+n+"."+l+"');conta-- CLASS=menuIE onClick=vai('"+links[i][l]+"',"+i+","+l+")>&nbsp;"+voci[i][l]+"</DIV>"); // <- per modificare le impostazioni delle sottoliste
        }
    }

timer=setInterval("NascondiMenu()",800)

function NascondiMenu()
    {
    if (conta==0)
        {
        coloratutti(true)
        timer=setTimeout("coloratutti(false)",0);
        timer=setTimeout("showdeps(last,false)",0);
        }
    }

function coloratutti(col)
    {
    colore=col?ron:roff;
    for (i=0;i<voci.length;i++)
        for (j=1;j<voci[i].length;j++)
            {
        if (nn)
            document.layers["mdep"+i+"."+j].bgColor=colore;
        else
            if(document.all)
                document.all["mdep"+i+"."+j].style.backgroundImage="url("+colore+")";
            else
                document.getElementById('mdep'+i+"."+j).style.backgroundImage="url("+colore+")";
            }
    }

function MostraMenu(n)
    {
    showdeps(last,false);
    showdeps(n,true);
    last=n;
    }

function showdeps(n,act)
    {
    if (conta==0)
        {
        act?stat="visible":stat="hidden";
    if (nn)
        for (i=1;i<voci[n].length;i++)
            document.layers["mdep"+n+"."+i].visibility=stat;
    else
        for (i=1;i<voci[n].length;i++)
            if(document.all)
                document.all["mdep"+n+"."+i].style.visibility=stat;
                else
                document.getElementById('mdep'+n+"."+i).style.visibility=stat;
        }
    }


function vai(dove,r,c)
    {
    bon=lev.backgroungImage="url("+ron+")"
    boff=lev.backgroungImage="url("+roff+")"
    lev=nn?document.layers["mdep"+r+"."+c]:(document.all)?document.all["mdep"+r+"."+c].style:document.getElementById("mdep"+r+"."+c).style;
    if (nn)
        {
        boff;
        timer=setTimeout("bon",50)
        timer=setTimeout("boff",100)
        timer=setTimeout("bon",150)
        timer=setTimeout("boff",200)
        timer=setTimeout("bon",250)
        }
    else
        {
        boff;
        timer=setTimeout("bon",50)
        timer=setTimeout("boff",100)
        timer=setTimeout("bon",150)
        timer=setTimeout("boff",200)
        timer=setTimeout("bon",250)
        }
    timer=setTimeout("self.location.href='"+dove+"'",350)
    }

function mroll(l)
    {
    nn?document.layers[l].backgroundImage="url("+ron+")":(document.all)?document.all[l].style.backgroundImage="url("+ron+")":document.getElementById(l).style.backgroundImage="url("+ron+")";
    document.getElementById?document.getElementById(l).style.cursor=document.all?'hand':'pointer':'void(0)';
    if (l.substr(0,4)=="mdep")
        stringa=wst[l.substr(4,l.indexOf(".")-4)][l.substring(l.indexOf(".")+1,l.length)];
    else if (l.length>5)
            stringa=wst[l.substr(4,l.indexOf(".")-4)][0];
        else stringa="Home Page";        
    window.status=stringa;
    timer=setTimeout("window.status=stringa",20);
    }

function unmroll(l)
    {
    nn?document.layers[l].backgroundImage="url("+roff+")":(document.all)?document.all[l].style.backgroundImage="url("+roff+")":document.getElementById(l).style.backgroundImage="url("+roff+")";
    window.status="";
    }
--></script>
</p>
</body>
</html>
Giusto per dare qualche informazione, mroll() e unmroll() sono le più plausibili come colpevoli, essendo loro che gestiscono la stampa nella status-bar del browser di quello che è scritto nell'Array 'wst', e soprattutto vai(), che gestisce invece un effetto blink prima di indirizzare al link scritto nell'Array links
Ciò che non va è che (in ordine di importanza):
1-quando clicko su un link, non mi viene ricaricata la pagina (dovrebbe comparire un # alla fine del link);
2-quando sono onMouseOver uno dei link, non mi viene mostrato il messaggio nella status-bar del browser;
3-l'effetto bilnk alla click su un link non c'è...
[vedete nello spoiler per maggiori info]
 
Ultima modifica:
Pubblicità
Pubblicità
Indietro
Top