Dynamic HTML

Skryptomania

Rozwijalna lista.

1/2

Skrypt ten dzia│a pod Netscapem Navigatorem 4.x oraz Microsoft Explorerem 4.x.

Rozwijalna lista polega na stworzeniu skryptu ukrywaj╣cego czΩ£µ strony do momentu gdy naci£niemy przycisk.Aby zaprezentowaµ ten skrypt musimy stworzyµ plik o nazwie np: przyklad.html i umieszczamy w nim poni┐szy kod miΩdzy znacznikami <HEAD> </HEAD>:

<STYLE TYPE="text/css">
<!--
H3 {
    font-family: Arial, Helvetica, Verdana;
    font-size: 10pt;
    font-weight: bold;
}
H3.real {
    font-family: Arial, Helvetica, Verdana;
    font-size: 14pt;
    font-weight: bold;
}
-->
</STYLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
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>");
}
}
isExpanded = false;

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 (NS4) {
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";
}
arrange();
}
else {
tempColl = document.all.tags("DIV");
for (i=0; i<tempColl.length; i++) {
if (tempColl(i).className == "child") tempColl(i).style.display = "none";
}
}
}
function showAll() {
    for (i=firstInd; i<document.layers.length; i++) {
        whichEl = document.layers[i];
        whichEl.visibility = "show";
    }
}
function expandIt(el) {
if (!ver4) return;
if (IE4) {expandIE(el)} else {expandNS(el)}
}

function expandIE(el) {
whichEl = eval(el + "Child");
whichIm = event.srcElement;
if (whichEl.style.display == "none") {
whichEl.style.display = "block";
whichIm.src = "triUp.gif";
}
else {
whichEl.style.display = "none";
whichIm.src = "triDown.gif";
}
}

function expandNS(el) {
whichEl = eval("document." + el + "Child");
whichIm = eval("document." + el + "Parent.document.images['imEx']");
if (whichEl.visibility == "hide") {
whichEl.visibility = "show";
whichIm.src = "triUp.gif";
}
else {
whichEl.visibility = "hide";
whichIm.src = "triDown.gif";
}
arrange();
}

function expandAll(isBot) {
newSrc = (isExpanded) ? "triDown.gif" : "triUp.gif";

if (NS4) {
document.images["imEx"].src = newSrc;
for (i=firstInd; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id.indexOf("Parent") != -1) {
whichEl.document.images["imEx"].src = newSrc;
}
if (whichEl.id.indexOf("Child") != -1) {
whichEl.visibility = (isExpanded) ? "hide" : "show";
}
}

arrange();
if (isBot && isExpanded) scrollTo(0,document.layers[firstInd].pageY);
}
else {
divColl = document.all.tags("DIV");
for (i=0; i<divColl.length; i++) {
if (divColl(i).className == "child") {
divColl(i).style.display = (isExpanded) ? "none" : "block";
}
}
imColl = document.images.item("imEx");
for (i=0; i<imColl.length; i++) {
imColl(i).src = newSrc;
}
}

isExpanded = !isExpanded;
}

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

onload = initIt;
//-->
</SCRIPT>

Reszta skryptu na nastΩpnej stronie.

 

Je£li masz jakie£ uwagi to:

Dane techniczne:

Masz jakie£ w╣ty to malnij do mnie!!!

Opracowanie graficzne i merytoryczne - Cruger dnia 15 lipiec, 1998.Strona zosta│a opracowana dla przegl╣darek Netscape'a4.x i Explorera4.x w rozdzielczo£ci 800x600 lub wy┐szej.