Avatar billede bojohansen Nybegynder
05. februar 2001 - 21:38 Der er 2 kommentarer og
1 løsning

Kan dette laves om så det stadigt er cross browser compatibelt?

Denne kode er fra en Extension til Macromedia Dreamweaver (UltraDev).
Kan den laves om så ledes at når der klikkes på en Hovedmenu linie så lukker en anden som er åben???

Her er en kode med to hoved menuer

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
</head>

<body bgcolor=\"#FFFFFF\" text=\"#000000\">
<script language=\"JavaScript1.2\">
NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
ver4 = (NS4 || IE4) ? 1 : 0;

if (ver4) {
    with (document) {
        write(\"<STYLE TYPE=\'text/css\'>\");
        if (NS4) {
            write(\".parent {position:absolute; visibility:visible}\");
            write(\".child {position:absolute; visibility:visible}\");
            write(\".regular {position:absolute; visibility:visible}\")
        }
        else {
            write(\".child {display:none}\")
        }
        write(\"</STYLE>\");
    }
}

function getIndex(el) {
    ind = null;
    for (i=0; i<document.layers.length; i++) {
        whichEl = document.layers[i];
        if (whichEl.id == el) {
            ind = i;
            break;
        }
    }
    return ind;
}

function arrange() {
    nextY = document.layers[firstInd].pageY +document.layers[firstInd].document.height;
    for (i=firstInd+1; i<document.layers.length; i++) {
        whichEl = document.layers[i];
        if (whichEl.visibility != \"hide\") {
            whichEl.pageY = nextY;
            nextY += whichEl.document.height;
        }
    }
}

function initIt(){
    if (!ver4) return;
    if (NS4) {
        for (i=0; i<document.layers.length; i++) {
            whichEl = document.layers[i];
            if (whichEl.id.indexOf(\"Child\") != -1) whichEl.visibility = \"hide\";
      }
        arrange();
    }
    else {
        divColl = document.all.tags(\"DIV\");
        for (i=0; i<divColl.length; i++) {
            whichEl = divColl(i);
            if (whichEl.className == \"child\") whichEl.style.display = \"none\";
        }
    }
}

function expandIt(el) {
    if (!ver4) return;
    if (IE4) {
        whichEl = eval(el + \"Child\");
        if (whichEl.style.display == \"none\") {
            whichEl.style.display = \"block\";
        }
        else {
            whichEl.style.display = \"none\";
        }
    }
    else {
        whichEl = eval(\"document.\" + el + \"Child\");
        if (whichEl.visibility == \"hide\") {
            whichEl.visibility = \"show\";
        }
        else {
            whichEl.visibility = \"hide\";
        }
        arrange();
    }
}

onload = initIt;

</script>
<div id=\"KB1Parent\" class=\"parent\"> <a href=\"#\" onClick=\"expandIt(\'KB1\'); return false\">
  I am main outline item #1 </a> </div>
<div id=\"KB1Child\" class=\"child\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I
  am sub outline item #1. Make me a link, alter me, or add more. I won\'t show
  up until my main item is clicked. </div>
<div id=\"KB2Parent\" class=\"parent\"> <a href=\"#\" onClick=\"expandIt(\'KB2\'); return false\">
  I am main outline item #2 </a> </div>
<div id=\"KB2Child\" class=\"child\"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I
  am sub outline item #2. Make me a link, alter me, or add more. I won\'t show
  up until my main item is clicked. </div>
<script language=\'JavaScript\'>
    if (NS4) {
        firstEl = \"KB1Parent\";
        firstInd = getIndex(firstEl);
        arrange();
    }
</script>
</body>
</html>


Og her er koden som ligger i den Extension inde i Dreamweaver

<HTML>
<HEAD>
<TITLE>Insert Cross Browser Expandable Outlines</TITLE>
<SCRIPT LANGUAGE=\"javascript\">
// Copyright (c) 1998 by Kevin Bartz. All rights reserved. kevinbartz@geocities.com.
var theStuff=\"\"
function objectTag() {

var items=parseInt(document.theForm.items.value)

theStuff+=\'<SCRIPT LANGUAGE=\"JavaScript1.2\">\\n\'
theStuff+=\"NS4 = (document.layers) ? 1 : 0;\\n\"
theStuff+=\"IE4 = (document.all) ? 1 : 0;\\n\"
theStuff+=\"ver4 = (NS4 || IE4) ? 1 : 0;\\n\"
theStuff+=\"\\n\"
theStuff+=\"if (ver4) {\\n\"
theStuff+=\"    with (document) {\\n\"
theStuff+=\'        write(\"<STYLE TYPE=\'
theStuff+=\"\'text/css\'>\"
theStuff+=\'\");\\n\'
theStuff+=\"        if (NS4) {\\n\"
theStuff+=\'            write(\".parent {position:absolute; visibility:visible}\");\\n\'
theStuff+=\'            write(\".child {position:absolute; visibility:visible}\");\\n\'
theStuff+=\'            write(\".regular {position:absolute; visibility:visible}\")\\n\'
theStuff+=\"        }\\n\"
theStuff+=\"        else {\\n\"
theStuff+=\'            write(\".child {display:none}\")\\n\'
theStuff+=\"        }\\n\"
theStuff+=\'        write(\"</STYLE>\");\\n\'
theStuff+=\"    }\\n\"
theStuff+=\"}\\n\"
theStuff+=\"\\n\"
theStuff+=\"function getIndex(el) {\\n\"
theStuff+=\"    ind = null;\\n\"
theStuff+=\"    for (i=0; i<document.layers.length; i++) {\\n\"
theStuff+=\"        whichEl = document.layers[i];\\n\"
theStuff+=\"        if (whichEl.id == el) {\\n\"
theStuff+=\"            ind = i;\\n\"
theStuff+=\"            break;\\n\"
theStuff+=\"        }\\n\"
theStuff+=\"    }\\n\"
theStuff+=\"    return ind;\\n\"
theStuff+=\"}\\n\"
theStuff+=\"\\n\"
theStuff+=\"function arrange() {\\n\"
theStuff+=\"    nextY = document.layers[firstInd].pageY +\"
theStuff+=\"document.layers[firstInd].document.height;\\n\"
theStuff+=\"    for (i=firstInd+1; i<document.layers.length; i++) {\\n\"
theStuff+=\"        whichEl = document.layers[i];\\n\"
theStuff+=\'        if (whichEl.visibility != \"hide\") {\\n\'
theStuff+=\"            whichEl.pageY = nextY;\\n\"
theStuff+=\"            nextY += whichEl.document.height;\\n\"
theStuff+=\"        }\\n\"
theStuff+=\"    }\\n\"
theStuff+=\"}\\n\"
theStuff+=\"\\n\"
theStuff+=\"function initIt(){\\n\"
theStuff+=\"    if (!ver4) return;\\n\"
theStuff+=\"    if (NS4) {\\n\"
theStuff+=\"        for (i=0; i<document.layers.length; i++) {\\n\"
theStuff+=\"            whichEl = document.layers[i];\\n\"
theStuff+=\'            if (whichEl.id.indexOf(\"Child\") != -1) whichEl.visibility = \"hide\";\\n\'
theStuff+=\"      }\\n\"
theStuff+=\"        arrange();\\n\"
theStuff+=\"    }\\n\"
theStuff+=\"    else {\\n\"
theStuff+=\'        divColl = document.all.tags(\"DIV\");\\n\'
theStuff+=\"        for (i=0; i<divColl.length; i++) {\\n\"
theStuff+=\"            whichEl = divColl(i);\\n\"
theStuff+=\'            if (whichEl.className == \"child\") whichEl.style.display = \"none\";\\n\'
theStuff+=\"        }\\n\"
theStuff+=\"    }\\n\"
theStuff+=\"}\\n\"
theStuff+=\"\\n\"
theStuff+=\"function expandIt(el) {\\n\"
theStuff+=\"    if (!ver4) return;\\n\"
theStuff+=\"    if (IE4) {\\n\"
theStuff+=\'        whichEl = eval(el + \"Child\");\\n\'
theStuff+=\'        if (whichEl.style.display == \"none\") {\\n\'
theStuff+=\'            whichEl.style.display = \"block\";\\n\'
theStuff+=\"        }\\n\"
theStuff+=\"        else {\\n\"
theStuff+=\'            whichEl.style.display = \"none\";\\n\'
theStuff+=\"        }\\n\"
theStuff+=\"    }\\n\"
theStuff+=\"    else {\\n\"
theStuff+=\'        whichEl = eval(\"document.\" + el + \"Child\");\\n\'
theStuff+=\'        if (whichEl.visibility == \"hide\") {\\n\'
theStuff+=\'            whichEl.visibility = \"show\";\\n\'
theStuff+=\"        }\\n\"
theStuff+=\"        else {\\n\"
theStuff+=\'            whichEl.visibility = \"hide\";\\n\'
theStuff+=\"        }\\n\"
theStuff+=\"        arrange();\\n\"
theStuff+=\"    }\\n\"
theStuff+=\"}\\n\"
theStuff+=\"\\n\"
theStuff+=\"onload = initIt;\\n\"
theStuff+=\"\\n\"
theStuff+=\"<\"+\"///\".substring(0,1)+\"SCRIPT>\\n\\n\"

var x=1
while (x <= items) {
theStuff+=\'<div id=\"KB\'
theStuff+=x
theStuff+=\'Parent\" class=\"parent\">\\n\'
theStuff+=\'<a href=\"#\" onclick=\"expandIt(\'
theStuff+=\"\'KB\"+x+\"\')\"
theStuff+=\'; return false\">\\n\'
theStuff+=\"I am main outline item #\"+x+\"\\n\"
theStuff+=\"</a>\\n\"
theStuff+=\"</div>\\n\"
theStuff+=\'<div id=\"KB\'
theStuff+=x
theStuff+=\'Child\" class=\"child\">\\n\'
theStuff+=\"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I am sub outline item #\"+x+\". Make me a link, alter me, or add more. I won\'t show up until my main item is clicked.\\n\"
theStuff+=\"</div>\\n\"
x++
}

theStuff+=\"<script language=\'JavaScript\'>\\n\"
theStuff+=\"    if (NS4) {\\n\"
theStuff+=\'        firstEl = \"KB1Parent\";\\n\'
theStuff+=\"        firstInd = getIndex(firstEl);\\n\"
theStuff+=\"        arrange();\\n\"
theStuff+=\"    }\\n\"
theStuff+=\"<\\/script>\"

return theStuff

}

</SCRIPT>
</HEAD>
<BODY>
<div align=\"center\">
<form method=\"post\" action=\"\" name=\"theForm\">
Number of main items(you may include as many sub-items as you want later):
<input type=\"text\" name=\"items\" size=24><br>
</form>
This will put down an outline, starting at the screen position top 50 and left 50. The division
names include a number to show what main outline member it is. They will also include either
\"child\" or \"parent.\" These indicate whether the item is a main, visible item, or an invisible
item underneath the main outline.
</div>
</BODY>
</HTML>

Først vil jeg vide om det kan lade sig gøre??? hvis det kan og du kan lave det, så får du 100 point :-)
vel og mærke hvis det virker som en extension!!
Avatar billede bojohansen Nybegynder
06. februar 2001 - 12:58 #1
Glem dette spørgsmål.
Avatar billede pixelpimp Nybegynder
02. marts 2001 - 10:35 #2

u dont say *LOOOOOOOL*

du aner jo tydeligvis ikke hvad der står :)

Ppimp
Avatar billede bojohansen Nybegynder
02. marts 2001 - 10:43 #3
Åhhhhhhhhhhhhh skal du nu til at husere over det hele Ppimp???

Hvis der er andre der ser dette ? så kig lige på http://www.eksperten.dk/spm/53469 hvor det tydeligt fremgår at Ppimp og chono er samme person, ignorer denne tumbe.
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