Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    due script che non coesistono

    Ragazzi sono nuovo di questo forum ed è il mio primo post... Sono alle prime armi pertanto un po di pazienza....................
    Sto cercando di far coesistere 2 scrip ma non c'è verso di farli funzionare entrambi nella stessa pagina. Singolarmente funzionano benissimo ma insieme smette di funzionare il menù
    Vi ringrazio se vorreste darmi una mano su come inserirli..........

    Il primo è un menu orizzontale a tendine mentre il secondo è uno scroll


    Vi posto i codici così come li ho trovati in rete e

    QUESTO E' IL CODICE DEL MENU

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 4.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <title>Laboratori</title>




    <style>
    body{background-color:#FFFFFF}
    A{color:gold; text-decoration:none}
    A:hover{color:red}
    A:visited:{color:#ff33cc}
    TD{font-family:arial,helvetica; font-size:10pt}
    DIV.clTopMenu{position:absolute; width:115; height:150; clip:rect(0,115,14,0); visibility:hidden; z-index:31; layer-background-color:#000000; background-color:#000000}
    DIV.clTopMenuBottom{position:absolute; width:115; height:3; clip:rect(0,115,3,0); top:16; layer-background-color:#000000; background-color:#000000; z-index:2}
    DIV.clTopMenuText{position:absolute; width:91; left:5; top:15; font-family:arial,helvetica; font-size:12px; background-color:#000000; z-index:1}
    </style>
    <script>

    /************************************************** ******************************

    ************************************************** ******************************
    Browsercheck:*/
    ie=document.all?1:0
    n=document.layers?1:0

    /************************************************** ******************************
    VARIABILI DA UTILIZZARE PER IL SET
    ************************************************** **************************/
    //How many menus do you have? (remember to copy and add divs in the body if you add menus)
    var numberOfMenus=1
    //The width on the menus (set the width in the stylesheet as well)
    var mwidth=115
    //Pixels between the menus
    var pxBetween=0
    //The first menus left position
    var fromLeft=33
    //The top position of the menus
    var fromTop=55
    //The bgColor of the bottom mouseover div
    var bgColor='#000000'
    //The bgColor to change to
    var bgColorChangeTo='#6380BC'
    //The position the mouseover line div will stop at when going up!
    var imageHeight=13
    /************************************************** *************************
    You shouldn't have to change anything below this
    ************************************************** **************************/
    //Object constructor
    function makeNewsMenu(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'
    this.css=(n) ? eval(nest+'document.'+obj):eval('document.all.'+ob j+'.style')
    this.scrollHeight=n?this.css.document.height:eval( 'document.all.'+obj+'.offsetHeight')
    this.moveIt=b_moveIt;this.bgChange=b_bgChange;
    this.slideUp=b_slideUp; this.slideDown=b_slideDown;
    this.clipTo=b_clipTo;
    this.obj = obj + "Object"; eval(this.obj + "=this")
    }
    //Objects methods
    function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y}
    function b_bgChange(color){if(ie) this.css.backgroundColor=color; else this.css.bgColor=color}
    function b_clipTo(t,r,b,l){
    if(n){this.css.clip.top=t; this.css.clip.right=r; this.css.clip.bottom=b; this.css.clip.left=l
    }else this.css.clip="rect("+t+","+r+","+b+","+l+")";
    }
    function b_slideUp(ystop,moveby,speed,fn,wh){
    if(!this.slideactive){
    if(this.y>ystop){
    this.moveIt(this.x,this.y-5); eval(wh)
    setTimeout(this.obj+".slideUp("+ystop+","+moveby+" ,"+speed+",'"+fn+"','"+wh+"')",speed)
    }else{
    this.slideactive=false; this.moveIt(0,ystop); eval(fn)
    }
    }
    }
    function b_slideDown(ystop,moveby,speed,fn,wh){
    if(!this.slideactive){
    if(this.y<ystop){
    this.moveIt(this.x,this.y+5); eval(wh)
    setTimeout(this.obj+".slideDown("+ystop+","+moveby +","+speed+",'"+fn+"','"+wh+"')",speed)
    }else{
    this.slideactive=false; this.moveIt(0,ystop); eval(fn)
    }
    }
    }
    //Initiating the page, making cross-browser objects
    function newsMenuInit(){
    oTopMenu=new Array()
    for(i=0;i<=numberOfMenus;i++){
    oTopMenu[i]=new Array()
    oTopMenu[i][0]=new makeNewsMenu('divTopMenu'+i)
    oTopMenu[i][1]=new makeNewsMenu('divTopMenuBottom'+i,'divTopMenu'+i)
    oTopMenu[i][2]=new makeNewsMenu('divTopMenuText'+i,'divTopMenu'+i)
    oTopMenu[i][1].moveIt(0,imageHeight)
    oTopMenu[i][0].clipTo(0,mwidth,imageHeight+3,0)
    oTopMenu[i][0].moveIt(i*mwidth+fromLeft+(i*pxBetween),fromTop)
    oTopMenu[i][0].css.visibility="visible"
    }
    }
    //Moves the menu
    function topMenu(num){
    if(oTopMenu[num][1].y==imageHeight) oTopMenu[num][1].slideDown(oTopMenu[num][2].scrollHeight+20,10,40,'oTopMenu['+num+'][0].clipTo(0,mwidth,oTopMenu['+num+'][1].y+3,0)','oTopMenu['+num+'][0].clipTo(0,mwidth,oTopMenu['+num+'][1].y+3,0)')
    else if(oTopMenu[num][1].y==oTopMenu[num][2].scrollHeight+20) oTopMenu[num][1].slideUp(imageHeight,10,40,'oTopMenu['+num+'][0].clipTo(0,mwidth,oTopMenu['+num+'][1].y+3,0)','oTopMenu['+num+'][0].clipTo(0,mwidth,oTopMenu['+num+'][1].y+3,0)')
    }
    //Changes background onmouseover
    function menuOver(num){oTopMenu[num][1].bgChange(bgColorChangeTo)}
    function menuOut(num){oTopMenu[num][1].bgChange(bgColor)}


    //Calls the init function onload
    onload=newsMenuInit;
    </script>


    <meta name="Microsoft Border" content="none">
    </head>

    <body background="000000">

    <table border="0" cellpadding="0" cellspacing="0" width="100%" height="250">
    </table>




    </p>


    <table border="0" cellpadding="0" cellspacing="0" width="100%" height="20">
    <tr>
    <td width="100%">
    <p align="center">
    </td>
    </tr>
    </table>
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
    <td width="2%" align="center"></td>
    <td width="96%" align="center" bgcolor="#000000"></td>
    <td width="2%" align="center"></td>
    </tr>
    </table>
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
    <td width="2%" align="center"></td>
    <td width="96%" align="center" bgcolor="#000000"></td>
    <td width="2%" align="center"></td>
    </tr>
    </table>
    <table border="0" cellpadding="0" cellspacing="0" width="100%" height="80">
    <tr>
    <td width="2%" align="center">
    <p align="center"></td>
    <td width="96%" align="center" bgcolor="#000000">
    </td>
    <td width="2%" align="center"></td>
    </tr>
    </table>




    <div id="divTopMenu0" class="clTopMenu"><a href="#" onmouseover="menuOver(0)" onmouseout="menuOut(0)" onclick="topMenu(0); if(ie)this.blur(); return false">
    [img] [/img]</a>
    <div id="divTopMenuText0" class="clTopMenuText">
    Laboratorio

    Software

    Attività 1

    Attività 2

    Galleria Foto

    </div>
    <div id="divTopMenuBottom0" class="clTopMenuBottom"></div>
    </div>



    <div id="divTopMenu1" class="clTopMenu"><a href="#" onmouseover="menuOver(1)" onmouseout="menuOut(1)" onclick="topMenu(1); if(ie)this.blur(); return false">
    [img]Pind.gif[/img]</a>
    <div id="divTopMenuText1" class="clTopMenuText">
    Laboratorio

    Software

    Attività

    Galleria Foto

    </div>
    <div id="divTopMenuBottom1" class="clTopMenuBottom">
    </div>
    </div>


    </body>

    </html>






    QUESTO E' IL CODICE SCROLL


    <html>
    <head>
    </head>
    <BODY bgcolor="white" >







    <script language="JavaScript1.2">
    <!--
    var scrollerwidth=150
    var scrollerheight=120
    var scrollerbgcolor='lightyellow'

    var messages=new Array()
    messages[0]="<font face='Arial'>Clicca qui per il primo link</font>"
    messages[1]="<font face='Arial'>Clicca qui per il secondo link</font>"
    messages[2]="<font face='Arial'>Clicca qui per il terzo link</font>"
    messages[3]="<font face='Arial'>Clicca qui per il quarto link</font>"
    messages[4]="<font face='Arial'>Ariclicca</font>"


    if (messages.length>1)
    i=2
    else
    i=0

    function move1(whichlayer){
    tlayer=eval(whichlayer)
    if (tlayer.top>0&&tlayer.top<=5){
    tlayer.top=0
    setTimeout("move1(tlayer)",3000)
    setTimeout("move2(document.main.document.second)", 3000)
    return
    }
    if (tlayer.top>=tlayer.document.height*-1){
    tlayer.top-=5
    setTimeout("move1(tlayer)",100)
    }
    else{
    tlayer.top=scrollerheight
    tlayer.document.write(messages[i])
    tlayer.document.close()
    if (i==messages.length-1)
    i=0
    else
    i++
    }
    }

    function move2(whichlayer){
    tlayer2=eval(whichlayer)
    if (tlayer2.top>0&&tlayer2.top<=5){
    tlayer2.top=0
    setTimeout("move2(tlayer2)",3000)
    setTimeout("move1(document.main.document.first)",3 000)
    return
    }
    if (tlayer2.top>=tlayer2.document.height*-1){
    tlayer2.top-=5
    setTimeout("move2(tlayer2)",100)
    }
    else{
    tlayer2.top=scrollerheight
    tlayer2.document.write(messages[i])
    tlayer2.document.close()
    if (i==messages.length-1)
    i=0
    else
    i++
    }
    }

    function move3(whichdiv){
    tdiv=eval(whichdiv)
    if (tdiv.style.pixelTop>0&&tdiv.style.pixelTop<=5){
    tdiv.style.pixelTop=0
    setTimeout("move3(tdiv)",3000)
    setTimeout("move4(second2)",3000)
    return
    }
    if (tdiv.style.pixelTop>=tdiv.offsetHeight*-1){
    tdiv.style.pixelTop-=5
    setTimeout("move3(tdiv)",100)
    }
    else{
    tdiv.style.pixelTop=scrollerheight
    tdiv.innerHTML=messages[i]
    if (i==messages.length-1)
    i=0
    else
    i++
    }
    }

    function move4(whichdiv){
    tdiv2=eval(whichdiv)
    if (tdiv2.style.pixelTop>0&&tdiv2.style.pixelTop<=5){
    tdiv2.style.pixelTop=0
    setTimeout("move4(tdiv2)",3000)
    setTimeout("move3(first2)",3000)
    return
    }
    if (tdiv2.style.pixelTop>=tdiv2.offsetHeight*-1){
    tdiv2.style.pixelTop-=5
    setTimeout("move4(second2)",100)
    }
    else{
    tdiv2.style.pixelTop=scrollerheight
    tdiv2.innerHTML=messages[i]
    if (i==messages.length-1)
    i=0
    else
    i++
    }
    }

    function startscroll(){
    if (document.all){
    move3(first2)
    second2.style.top=scrollerheight
    }
    else if (document.layers){
    move1(document.main.document.first)
    document.main.document.second.top=scrollerheight+5
    document.main.document.second.visibility='show'
    }
    }

    window.onload=startscroll
    -->
    </script>




    <ilayer id="main" width=&{scrollerwidth}; height=&{scrollerheight}; bgColor=&{scrollerbgcolor};>
    <layer id="first" left=0 top=1 width=&{scrollerwidth};>
    <script language="JavaScript1.2">
    if (document.layers)
    document.write(messages[0])
    </script>
    </layer>
    <layer id="second" left=0 top=0 width=&{scrollerwidth}; visibility=hide>
    <script language="JavaScript1.2">
    if (document.layers)
    document.write(messages[1])
    </script>
    </layer>
    </ilayer>

    <script language="JavaScript1.2">
    <!--
    if (document.all){
    document.writeln('<span id="main2" style="position:relative;width:'+scrollerwidth+';h eight:'+scrollerheight+';overflow:hiden;background-color:'+scrollerbgcolor+'">')
    document.writeln('<div style="position:absolute;width:'+scrollerwidth+';h eight:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0;top:0">')
    document.writeln('<div id="first2" style="position:absolute;width:'+scrollerwidth+';l eft:0;top:1;">')
    document.write(messages[0])
    document.writeln('</div>')
    document.writeln('<div id="second2" style="position:absolute;width:'+scrollerwidth+';l eft:0;top:0">')
    document.write(messages[1])
    document.writeln('</div>')
    document.writeln('</div>')
    document.writeln('</span>')
    }
    -->
    </script>


    </body>
    </html>

  2. #2
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    rimuovere questo
    window.onload=startscroll
    e cambiare questo
    onload=newsMenuInit;
    in questo
    window.onload=function(){newsMenuInit();startscrol l();}
    potrebbe bastare
    ciao

  3. #3
    xinod ti ringrazio per l'aiuto e non vorrei abusare della disponibilità ma c'è ancora un problema. Effettivamente ora funzionano entrambi gli script però nello scroll, dopo i primi due link, in anteprima scorre all'infinito il termine " UNDEFINED ". Ogni volta che vado in anteprima stesso problema. Come posso risolvere?
    Di nuovo grazie per l'aiuto

  4. #4
    up up
    Proprio non riesco a risolverlo.
    Un aiutino?
    Thanks

  5. #5
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    quello che qualsiasi editor fa vedere in modalita' anteprima vale un fico secco
    apri la pagina in un browser senza passare dall' editor e vedi cosa succede,
    io con quello che tu hai postato non ottengo errori
    quindi, se fuori dall' editor si verifica quanto affermi, avrai cambiato qualcosa rispetto a quanto postato
    altro non riesco ad immaginarmi

  6. #6
    Hai perfettamente ragione. Nel browser va benissimo.... meglio andava perchè studiando nel corso javascript di questo sito ho imparato a inserire gli script da file esterni con estensione *.js prodotti con il notepad. Ora è tutto più in ordine e naturalmente funziona perfettamente il tutto
    Grazie e alla prossima

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.