Michele Basso
a- a+

Menù in stile Windows con PopUp

Quest'oggi vedremo come inserire un menùrealizzato interamente in dhtml; graficamente assomigliamoltissimo ai menù di windows, e per il funzionamentoutilizza una finestra PopUp.

Lo script non è difficile da installare, basta solofare attenzione quando lo si adatta alla pagina in cui lovogliamo inserire.

Per prima cosa dobbiamo inserire degli stili(CSS); il codiceè il seguente:

<STYLE TYPE="text/css"><!--#text {POSITION: absolute;Z-INDEX: 1;LEFT: 10px;TOP: 5px;}#iDL {POSITION: absolute;Z-INDEX: 1;LEFT: 10px;TOP: 150px;}--></style>

In seguito, inseriamo questo codice all'interno del tagbody

<DIV ID="iDL" CLASS="iconNav">Apri menù</DIV><div id="text">Menù popup</div><OBJECT ID="Menu1" WIDTH=0 HEIGHT=0    CLASSID="CLSID:F5131C24-E56D-11CF-B78A-444553540000"    CODEBASE="#version=1,0,0,9">    <PARAM NAME="_Version" VALUE="65536">    <PARAM NAME="_ExtentX" VALUE="2646">    <PARAM NAME="_ExtentY" VALUE="1323">    <PARAM NAME="_StockProps" VALUE="0"></OBJECT><SCRIPT LANGUAGE="VBScript"><!--dim Site, ImgdirSite = "http://" & location.hostImgdir = Site + "/ie/images/topnav/"dim menu1Readymenu1Ready = falsesub document_onMouseover()    dim srcElement    set srcElement = window.event.srcElement    if srcElement.classname = "iconNav" then  srcElement.style.color = "#00A8FF"  window.event.cancelBubble = true    end ifend subsub document_onMouseout()    dim srcElement    set srcElement = window.event.srcElement    if srcElement.classname = "iconNav" then  srcElement.style.color = "black"  window.event.cancelBubble = true    end ifend subsub document_onClick()    if (document.all.Menu1.readyState = 4) Or (document.all.Menu1.readyState = "complete") then menu1Ready = true    dim srcElement    set srcElement = window.event.srcElement    select case srcElement.id    case "iHome"  top.location.href= Site + "/ie/default.asp"    case "iProd"  if menu1Ready thenProd_Menu  elseproductInfo()  end if    case "iDL"  if menu1Ready thenDown_Menu()  elsedownload()  end if    end selectend subsub Menu1_Onclick(id)    url = menu1.GetItemValue(id)    top.location.href=urlend subSub window_onbeforeunload()    if menu1Ready then call Menu1.RemoveAllItems()end subsub Ad (cde,lbl,menuitem,par)    dim temp    temp = lbl'   if lcase(cde)=MarkMenu then' temp = ">" & temp'   else  temp = "  " & temp'   end if    Menu1.AddItem cde,temp,menuitem,parend subSub Down_Menu()    Menu1.RemoveAllItems    Ad "ieDL_Over" ,"DHTML Demos Home Page" ,"http://www.ruleweb.com/dhtml/" ,""    Ad "ieDL_IE4" ,"Internet Explorer 4.0 Demos" ,"http://www.ruleweb.com/dhtml/" ,""  Ad "ieDL4_W32" ,"Pop Out Menu" ,"../popoutnetscape/popout.html" ,"ieDL_IE4"  Ad "ieDL4_W16" ,"Preview Presentation" ,"../preview/preview.html" ,"ieDL_IE4"  Ad "ieDL4_Mac" ,"Sequencer JS" ,"../sequence/sequence.html" ,"ieDL_IE4"  Ad "ieDL4_Unix" ,"Sequencer Active X" ,"../Sequence/jeffsequencex.html" ,"ieDL_IE4"    Ad "ieDL_IE4c" ,"Internet Explorer 4.0 Components" ,"http://www.microsoft.com/ie/ie40/download/?/ie/ie40/download/addon.htm" ,""    Ad "ieDL_IE3c" ,"Netscape 4.0 Demos" ,"" ,""  Ad "ieDL_citx" ,"Drag and Drop" ,"http://developer.netscape.com/library/examples/dynhtml/dragable/index.html" ,"ieDL_IE3c"  Ad "ieDL_html" ,"Horizontal Wipe" ,"../netscape/horizontalwipe.html" ,"ieDL_IE3c"  Ad "ieDL_shock" ,"Animation" ,"../netscape/animation.html" ,"ieDL_IE3c"  Ad "ieDL_mls" ,"Skeleton Game" ,"../Skeleton/skeletonheadworksx.html" ,"ieDL_IE3c"    call Menu1.Popup (100,104)end sub--></SCRIPT>

Tutte le voci del menù sono configurabili tramite ilcodice che abbiamo inserito nel tag body.

Per qualsiasi problema relativo all'installazione, potetesempre consultare il nostroforum.