Avatar billede sad-peter-pan Nybegynder
03. september 2002 - 07:10 Der er 7 kommentarer og
1 løsning

JS menu

Dav.. Jeg ved ikke rigtigt noget om nogen form for programmering :D.. Så jeg har stjålet et script fra et andet sprøgsmål her opå siden...

Men jeg kan ikke få menuen til at virke korrekt.. Dvs - Når musen er ført over linksne een gang, forsvinder linksne (?)..

Hvem vil hjælpe ? :D

URL : http://www.ymer.h4f.dk/top.shtml
Avatar billede yousif Nybegynder
03. september 2002 - 07:37 #1
Prøv at se om du kan bruge denne:

www.dhtmlcentral.com

kig under coolmenus
Avatar billede yousif Nybegynder
03. september 2002 - 07:44 #2
Avatar billede sad-peter-pan Nybegynder
03. september 2002 - 08:04 #3
Jeg vil hellere have den ger til at virke... er der ikke nogen som kan hjælpe mig med det? - Den fra dhtml central har jeg faktisk prøvet lidt med, men jeg synes at den er lidt for inviklet :P...
Avatar billede yousif Nybegynder
03. september 2002 - 08:08 #4
sad-peter-pan> det mener du da ikk!

jeg laver en til dig .. 2 sekunder..
Avatar billede yousif Nybegynder
03. september 2002 - 08:10 #5
jeg vil ikke lave en nu.. men jeg fandt en fra thomas bratti som jeg tror du kan finde rundt i (MEGET SIMPELT):

<html>
<head>
<style>
A:hover{color:red}
#divBg{position:absolute; top:0; left:0; visibility:hidden; height:50}
DIV.clSub{position:relative; top:-5; font-family:arial,helvetica; font-size:12px; padding:10px; visibility:hidden; background-color:Silver; layer-background-color:Silver}
</style>
<script language="JavaScript1.2">
/********************************************************************************
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!
********************************************************************************
Browsercheck:*/
ie=document.all?1:0
n=document.layers?1:0

//Do you want it to move with the page if the user scroll the page?
var moveOnScroll=true

//Do you want to hide all the other submenus when you click a new?
var hideAll=true

/********************************************************************************
If you want to change the appearans on the text, or background or anything
do that in the style tag above, or in the table tag below.

NOTE: This menu have some "small" bugs.
In Netscape the links in the submenus will work even though the
submenus are hidden, this has something to do with
a lousy implementation of the relative positioning in Netscape.
In IE links "underneath" the submenus will not work even though the
submenus are hidden.
I will look into this and might find a fix for it.
********************************************************************************/


/********************************************************************************
Object constructor
********************************************************************************/
function makeMenuBar(obj,nest,vis){
    nest=(!nest) ? '':'document.'+nest+'.'
    this.css=(n) ? eval(nest+'document.'+obj):eval(obj+'.style')
    this.hideIt=b_hideIt;    this.showIt=b_showIt; this.vis=b_vis                       
    if(ie && vis) this.css.visibility='hidden'
    this.state=1
    this.go=0
    this.height=n?this.css.document.height:eval(obj+'.offsetHeight')
    this.top=b_gettop
    this.obj = obj + "Object";     eval(this.obj + "=this")   
}
//Get's the top position.
function b_gettop(){
    var gleft=(n) ? eval(this.css.top):eval(this.css.pixelTop);
    return gleft;
}
//The functions for showing and hiding
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;
}
/********************************************************************************
Checking if the page is scrolled, if it is move the menu after
********************************************************************************/
function checkScrolled(){
    if(!oMenu.go)oMenu.css.top=(!oMenu.state)?eval(scrolled):eval(scrolled)
    if(n) setTimeout('checkScrolled()',30)
}
/********************************************************************************
Inits the page, makes the menu object, moves it to the right place,
show it..
********************************************************************************/
function menuBarInit(){
    oSub=new Array()
    //Change it here if you want more or less submenus.
    oSub[0]=new makeMenuBar('divSub0','divBg',1)
    oSub[1]=new makeMenuBar('divSub1','divBg',1)
    oSub[2]=new makeMenuBar('divSub2','divBg',1)
    oSub[3]=new makeMenuBar('divSub3','divBg',1)
    oSub[4]=new makeMenuBar('divSub4','divBg',1)
    //Moving menuBar
    oMenu=new makeMenuBar('divBg')
    scrolled=n?"window.pageYOffset":"document.body.scrollTop"
    oMenu.css.top=eval(scrolled)
    oMenu.css.visibility='visible'
    if(moveOnScroll) ie?window.onscroll=checkScrolled:checkScrolled();
}

/********************************************************************************
Shows and hides the submenus
********************************************************************************/
function extract(num){
    if(hideAll){
        for(i=0;i<oSub.length;i++){
            if(num!=i) oSub[i].hideIt()
        }
    }
    !oSub[num].vis()?oSub[num].hideIt():oSub[num].showIt();

}

onload=menuBarInit;
</script>
</head>
<body bgcolor="White">
<div id="divBg">
<table width="102%" border="0" cellspacing="0" cellpadding="5" align="CENTER" valign="MIDDLE">
    <tr bgcolor="#C0C0C0">
        <td height="30"><a href="#" onclick="extract(0); return false">Choice 1</a></td>
        <td><a href="#" onclick="extract(1); return false">Choice 2</a></td>
        <td><a href="#" onclick="extract(2); return false">Choice 3</a></td>
        <td><a href="#" onclick="extract(3); return false">Choice 4</a></td>
        <td><a href="#" onclick="extract(4); return false">Choice 5</a></td>
    </tr>
    <!-- If you don't want submenu, just remove this tr and
    remove the onclicks above and change the #'s to links -->
    <tr>
        <td valign="TOP">
        <div id="divSub0" class="clSub">
            <!-- To make the links link somewhere, just replace the #'s
            with the link location -->
            <a href="#">Sub choice 1</a>    <br>
            <a href="#">Sub choice 2</a><br>
            <a href="#">Sub choice 3</a><br>
            <a href="#">Sub choice 4</a><br>
            <a href="#">Sub choice 5</a>
        </div>
        </td>
        <td valign="TOP">
        <div id="divSub1" class="clSub">
            <a href="#">Sub choice 1</a>    <br>
            <a href="#">Sub choice 2</a><br>
            <a href="#">Sub choice 3</a>
        </div>
        </td>
        <td valign="TOP">
        <div id="divSub2" class="clSub">
            <a href="#">Sub choice 1</a>    <br>
            <a href="#">Sub choice 2</a>
        </div>
        </td>
        <td valign="TOP">
        <div id="divSub3" class="clSub">
            <a href="#">Sub choice 1</a>    <br>
            <a href="#">Sub choice 2</a><br>
            <a href="#">Sub choice 3</a><br>
            <a href="#">Sub choice 4</a><br>
            <a href="#">Sub choice 5</a>
        </div>
        </td>
        <td valign="TOP">
        <div id="divSub4" class="clSub">
            <a href="#">Sub choice 1</a>    <br>
            <a href="#">Sub choice 2</a><br>
            <a href="#">Sub choice 3</a><br>
            <a href="#">Sub choice 4</a>
        </div>
        </td>
    </tr>
</table>
</div>
</body>
</html>
Avatar billede yousif Nybegynder
03. september 2002 - 09:23 #6
sker der noget?? kunne du bruge det?
Avatar billede sad-peter-pan Nybegynder
03. september 2002 - 14:21 #7
Ja, det tror jeg godt at jeg kan :) - Har været i skole så har ikke kunnet skrive så meget :D
Avatar billede sad-peter-pan Nybegynder
04. september 2002 - 09:26 #8
taaaak for hjælpen :)
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
IT-kurser om Microsoft 365, sikkerhed, personlig vækst, udvikling, digital markedsføring, grafisk design, SAP og forretningsanalyse.

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