Avatar billede mr.gessle Nybegynder
12. september 1999 - 16:10 Der er 2 kommentarer og
1 løsning

Menu-system med drop-down effekt

Jeg leder efter et script, som fungerer på samme måde som set på www.erfarkons.dk. Er der nogle, som ved hvor et sådant script eller lign. kan hentes fra?
Avatar billede nof Nybegynder
12. september 1999 - 18:23 #1
Se et af disse spørgsmål:
http://www.eksperten.dk/spm.asp?id=270
http://www.eksperten.dk/spm.asp?id=1821

Eller brug denne kode:
<html>
<head>
    <title>Cross-browser Dynamic HTML - Foldout menu 2 script</title>
<meta name="Author" content="Thomas Brattli (webmaster@bratta.com)">
<meta name="KeyWords" content="DHTML, HTML, dhtml, html, demos, Javascript, VBscript, Cross-browser, Netscape4.0, IE4.0, Internet explorer, Dynamic HTML">
<meta name="Description" content="This DHTML script foldes out and in sub menu items">
<style>
TD{font-family:arial,helvetica; font-size:10pt}
BODY{background-color:white}
A{color:Navy; text-decoration:none}
A:hover{color:red}
A:visited:{color:#808080}
</style>
<style>
<!--
DIV.clTop{position:absolute; width:170}
DIV.clSub{position:absolute; left:10; width:170}
#divCont{position:relative; left:100; top:0; height:400; width:170;}
A.clMain{font-family:Arial, Verdana, Helvetica, Helv; font-size:14px; text-decoration:none; font-weight:bold; color:black}
A.clSubb{font-family:Arial, Verdana, Helvetica, Helv; font-size:14px; text-decoration:none; color:black}
#divMain{position:absolute}
//-->
</style>
<script language="JavaScript">
/********************************************************************************
Copyright (C) 1999 Thomas Brattli
This script is made by and copyrighted to Thomas Brattli at www.bratta.com
Visit for more great scripts.
This may be used freely as long as this msg is intact!
********************************************************************************/

/************************************************************************************
This script is a "foldout" menu script, all the "foldouts" will
stay outfolded in older browsers. Works in ie4+ and ns4+.
ADDED: Images

To change where the menu appears change the left and top values of the divCont
in the stylesheets, it's currently placed relative so you can
place this menu in tables or similar if you want. Change the
text colors and size in the A.clMain and A.clSubb classes.
************************************************************************************/

/************************************************************************************
Change this to false if you want all the submenus to get unfold when you
foldout a new one.
************************************************************************************/
var stayFolded=false

//This is the image that it changes to when it expands.
var exImg=new Image(); exImg.src='images/arrow1.gif'
//This is the image is changes to with it's "unfolded" or something :}
//Remeber to change the actual images in the page aswell, but remember to
//keep the name of the image.
var unImg=new Image(); unImg.src='images/arrow.gif'

/************************************************************************************
Browsercheck
************************************************************************************/
var n = (document.layers) ? 1:0;
var ie = (document.all) ? 1:0;
var browser=((n || ie) && parseInt(navigator.appVersion)>=4) 

/************************************************************************************
Making cross-browser objects
************************************************************************************/
function makeMenu(obj,nest){
    nest=(!nest) ? '':'document.'+nest+'.'                                       
    this.css=(n) ? eval(nest+'document.'+obj):eval('document.all.'+obj+'.style')                   
      this.ref=(n) ? eval(nest+'document.'+obj+'.document'):eval('document');       
    this.height=n?this.ref.height:eval(obj+'.offsetHeight')
    this.x=(n)? this.css.left:this.css.pixelLeft;this.y=(n)? this.css.top:this.css.pixelTop;                           
    this.hideIt=b_hideIt;    this.showIt=b_showIt; this.vis=b_vis; this.moveIt=b_moveIt                                           
    return this
}
function b_showIt(){this.css.visibility="visible"}
function b_hideIt(){this.css.visibility="hidden"}
function b_vis(){if(this.css.visibility=="hidden" || this.css.visibility=="hide") return true;}
function b_moveIt(x,y){this.x=x; this.y=y; this.css.left=this.x; this.css.top=this.y}
/************************************************************************************
Initiating the page. Just add to the arrays here to get more menuitems
and add divs in the page
************************************************************************************/
function init(){
    oTop=new Array()
    oTop[0]=new makeMenu('divTop1','divCont')
    oTop[1]=new makeMenu('divTop2','divCont')
    oTop[2]=new makeMenu('divTop3','divCont')
    oTop[3]=new makeMenu('divTop4','divCont')
    oTop[4]=new makeMenu('divTop5','divCont')
    oTop[5]=new makeMenu('divTop6','divCont')
    oSub=new Array()
    oSub[0]=new makeMenu('divSub1','divCont.document.divTop1')
    oSub[1]=new makeMenu('divSub2','divCont.document.divTop2')
    oSub[2]=new makeMenu('divSub3','divCont.document.divTop3')
    oSub[3]=new makeMenu('divSub4','divCont.document.divTop4')
    oSub[4]=new makeMenu('divSub5','divCont.document.divTop5')
    oSub[5]=new makeMenu('divSub6','divCont.document.divTop6')
    for(i=0;i<oSub.length;i++){ oSub[i].hideIt() }
    for(i=1;i<oTop.length;i++){ oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height) }
}
/************************************************************************************
This is the function that changes the sub menus to folded or unfolded state.
************************************************************************************/
function menu(num){
    if(browser){
        if(!stayFolded){
            for(i=0;i<oSub.length;i++){
                if(i!=num){
                    oSub[i].hideIt()
                    oTop[i].ref["imgA"+i].src=unImg.src
                }
            }
            for(i=1;i<oTop.length;i++){
                oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height)
            }
        }
        if(oSub[num].vis()){
            oSub[num].showIt()
            oTop[num].ref["imgA"+num].src=exImg.src
        }else{
            oSub[num].hideIt()
            oTop[num].ref["imgA"+num].src=unImg.src
        }
        for(i=1;i<oTop.length;i++){
            if(!oSub[i-1].vis()) oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height+oSub[i-1].height)
            else oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height)
        }
    }
}
//Initiating the menus onload, if it's a 4.x+ browser.
if(browser) onload=init;

</script>

</HEAD>
<BODY bgcolor="white">
<table width="80%" align="center">
<tr>
    <td>
        <h3>Cross-browser DHTML Script - Foldout Menu 2</h3>
        The difference between this and the first <a href="foldmenu.html">foldout menu</a>
        is that this one also have images.<br>
        This is a great foldout menu, works in 2 different ways.
        Similar to the new quickmenu at the main page.<br>
        Click <a href="#" onclick="if(stayFolded)stayFolded=false; else stayFolded=true">here</a> to change it's behaviour.
        <p align="right">
            <a href="foldmenu2_source.html">[get source]</a>
        <script>
            if(self.name=="scriptWin") document.write('<a href="#" onclick="self.close()">[close window]</a>')
            else if(self.name!="frmMain")document.write('<a href="../index.html?noanim,pages/1.html">[back]</a>')
        </script>
    </td>
</tr>
</table>
<!--************************************************************************************
Replace your links with the # inside the a tags to get links.
************************************************************************************-->
<div id="divCont">
    <div id="divTop1" class="clTop"><a href="#" onclick="menu(0); return false" class="clMain"><img src="images/arrow.gif" name="imgA0" width=12 height=12 alt="" border="0"> [choice 0]</a><br>
        <div id="divSub1" class="clSub">
            &nbsp;<a href="#" class="clSubb">-Sub 1</a><br>
            &nbsp;<a href="#" class="clSubb">-Sub 2</a><br>
            &nbsp;<a href="#" class="clSubb">-Sub 3</a><br>
            &nbsp;<a href="#" class="clSubb">-Sub 4</a><br>
        </div><br>
    </div>
    <div id="divTop2" class="clTop"><a href="#" onclick="menu(1); return false" class="clMain"><img src="images/arrow.gif" name="imgA1" width=12 height=12 alt="" border="0"> [choice 1]</a><br>
        <div id="divSub2" class="clSub">
            &nbsp;<a href="#" class="clSubb">-Sub 1</a><br>
            &nbsp;<a href="#" class="clSubb">-Sub 2</a><br>
        </div><br>
    </div>
    <div id="divTop3" class="clTop"><a href="#" onclick="menu(2); return false" class="clMain"><img src="images/arrow.gif" name="imgA2" width=12 height=12 alt="" border="0"> [choice 2]</a><br>
        <div id="divSub3" class="clSub">
            &nbsp;<a href="#" class="clSubb">-Sub 1</a><br>
            &nbsp;<a href="#" class="clSubb">-Sub 2</a><br>
            &nbsp;<a href="#" class="clSubb">-Sub 3</a><br>
        </div><br>
    </div>
    <div id="divTop4" class="clTop"><a href="" onclick="menu(3); return false" class="clMain"><img src="images/arrow.gif" name="imgA3" width=12 height=12 alt="" border="0"> [choice 3]</a><br>
        <div id="divSub4" class="clSub">
            &nbsp;<a href="#" class="clSubb">-Sub 1</a><br>
            &nbsp;<a href="#" class="clSubb">-Sub 2</a><br>
        </div><br>
    </div>
    <div id="divTop5" class="clTop"><a href="" onclick="menu(4); return false" class="clMain"><img src="images/arrow.gif" name="imgA4" width=12 height=12 alt="" border="0"> [choice 4]</a><br>
        <div id="divSub5" class="clSub">
            &nbsp;<a href="#" class="clSubb">-Sub 1</a><br>
            &nbsp;<a href="#" class="clSubb">-Sub 2</a><br>
            &nbsp;<a href="#" class="clSubb">-Sub 3</a><br>
            &nbsp;<a href="#" class="clSubb">-Sub 4</a><br>
            &nbsp;<a href="#" class="clSubb">-Sub 5</a><br>
        </div><br>
    </div>
    <div id="divTop6" class="clTop"><a href="" onclick="menu(5); return false" class="clMain"><img src="images/arrow.gif" name="imgA5" width=12 height=12 alt="" border="0"> [choice 5]</a><br>
        <div id="divSub6" class="clSub">
            &nbsp;<a href="#" class="clSubb">-Sub 1</a><br>
        </div><br>
    </div>
</div>
</BODY>
</HTML>

Mvh
nof
Avatar billede mr.gessle Nybegynder
12. september 1999 - 20:01 #2
Meget udført svar. Takker mange gange
Avatar billede nof Nybegynder
12. september 1999 - 21:02 #3
...det var så lidt!

Mvh
nof
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester