Der folgende Beitrag wurde am 26. 05. 1999, 17:51 Uhr von Hendrik Otting veröffentlicht.
Hi
habe folgendes javascript erstellt. Funktioniert sogar unter NS wie IE, aber was mich stört, sind der übermäßige Gebrauch von "eval" und die unmenge an "DIV"-tags. Habe mehrere Haare und Nerven bei dem Versuch verloren eine einfachere Lösung für NS UND IE zu finden. Vieleicht kann jemand das script brauchen oder mir nen Tip zur vereinfachung geben.
Die gifs, welche abgespielt werden sind die einzelnen frames des standart "sylvest.gif" mit einigen leerframes in richtiger reihenfolge. (oder gibts ne möglichkeit abzufragen wann der erste frame eines anim gif gezeigt wird ?)
Die Variablen Z3 und Z4 solten mal zur grössenänderung der bilder genutzt werden... klappte aber auch noch nicht.
Die Variablen z11 - z14 solten mal für ein zweites objekt genutzt werden ... hatte nur kein nerv alle die div-tags nochmal zu pasten.
Function show und hide sind geklaut, erschienen mir die sinnvollsten lösungen...
Mfg
Hendrik
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<meta name="author" content="Hendrik Otting">
<html>
<head>
<title>Feuerwerks</title>
</head>
<script language="JavaScript">
<!--
var ns = false;
var ie = false;
var screenx = 0;
var screeny = 0;
var obj = "";
var iestyle = "";
var speed = 33;
var t1 = 5;
var t2 = 10;
var firstloop = true;
var z1 = 50;
var z2 = 50;
var z3 = 50;
var z4 = 50;
var z11 = 50;
var z21 = 50;
var z31 = 50;
var z41 = 50;
var lastpic = 19;
var picarray1 = new Array (lastpic);
function init ()
{
for(i = 0; i <= lastpic; i++)
{
if (i <= 9 ) picarray1 [i] = "feuer00" + i ;
if (i > 9 ) picarray1 [i] = "feuer0" + i ;
hide (picarray1 [i]);
}
if (document.layers)
{ ns = true;
ie = false;
screenx = innerWidth;
screeny = innerHeight;
obj = "document.layers";
iestyle = "";
}
if (document.all)
{ ns = false;
ie = true;
screenx = document.body.offsetWidth;
screeny = document.body.offsetHeight;
obj = "document.all";
iestyle = ".style";
}
window.setTimeout ("timeloop()",speed);
}
function pos (what,leftf,topf)
{
eval(obj+'["'+what+'"]'+iestyle+'.top = topf');
eval(obj+'["'+what+'"]'+iestyle+'.left = leftf');
}
function rand (von,bis)
{
var rando = Math.random();
var zzahl = Math.floor((rando * bis) + von);
return zzahl;
}
function show(showobj) {
if (ns) eval ('document.'+showobj+'.visibility = "show"');
if (ie) eval ('document.all["'+showobj+'"].style.visibility = "visible"');
}
function hide(hideobj) {
if (ns) eval ('document.'+hideobj+'.visibility = "hide"');
if (ie) eval ('document.all["'+hideobj+'"].style.visibility = "hidden"');
}
function timeloop ()
{
t1++;
if (t1 == (lastpic+1)) {t1 = 0}
if (t1 == 0)
{
z1 = rand(0,screeny);
z2 = rand(0,screenx);
z3 = rand(50,150);
z4 = z3;
hide (picarray1 [lastpic]);
}
else {
hide (picarray1 [eval(t1-1)]);
}
pos (picarray1 [t1],z1,z2);
show (picarray1 [t1]);
window.setTimeout ("timeloop()",speed);
}
// -->
</script>
<body onLoad="init()">
<div id = "feuer000" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer000.gif" border="0" name = "feuer00" width = "100" height = "100">
</div>
<div id = "feuer001" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer001.gif" border="0" name = "feuer01" width = "100" height = "100">
</div>
<div id = "feuer002" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer002.gif" border="0" name = "feuer02" width = "100" height = "100">
</div>
<div id = "feuer003" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer003.gif" border="0" name = "feuer03" width = "100" height = "100">
</div>
<div id = "feuer004" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer004.gif" border="0" name = "feuer04" width = "100" height = "100">
</div>
<div id = "feuer005" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer005.gif" border="0" name = "feuer05" width = "100" height = "100">
</div>
<div id = "feuer006" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer006.gif" border="0" name = "feuer06" width = "100" height = "100">
</div>
<div id = "feuer007" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer007.gif" border="0" name = "feuer07" width = "100" height = "100">
</div>
<div id = "feuer008" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer008.gif" border="0" name = "feuer08" width = "100" height = "100">
</div>
<div id = "feuer009" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer009.gif" border="0" name = "feuer09" width = "100" height = "100">
</div>
<div id = "feuer010" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer010.gif" border="0" name = "feuer10" width = "100" height = "100">
</div>
<div id = "feuer011" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer011.gif" border="0" name = "feuer11" width = "100" height = "100">
</div>
<div id = "feuer012" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer012.gif" border="0" name = "feuer12" width = "100" height = "100">
</div>
<div id = "feuer013" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer013.gif" border="0" name = "feuer13" width = "100" height = "100">
</div>
<div id = "feuer014" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer014.gif" border="0" name = "feuer14" width = "100" height = "100">
</div>
<div id = "feuer015" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer015.gif" border="0" name = "feuer15" width = "100" height = "100">
</div>
<div id = "feuer016" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer016.gif" border="0" name = "feuer16" width = "100" height = "100">
</div>
<div id = "feuer017" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer017.gif" border="0" name = "feuer17" width = "100" height = "100">
</div>
<div id = "feuer018" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer018.gif" border="0" name = "feuer18" width = "100" height = "100">
</div>
<div id = "feuer019" style = "position:absolute; top:100px; left:100px; visibility:hidden;">
<img src="../../gfx/testgfx/feuer019.gif" border="0" name = "feuer19" width = "100" height = "100">
</div>
<CENTER>
<H6>
<FONT FACE="Courier New"><FONT SIZE=10>A B C D E F G H I J K L M N O P Q R S T U V W </FONT></FONT></H6>
</CENTER>
<CENTER>
<H6>
<FONT FACE="Courier New"><FONT SIZE=10>A B C D E F G H I J K L M N O P Q R S T U V W </FONT></FONT></H6>
</CENTER><CENTER>
<H6>
<FONT FACE="Courier New"><FONT SIZE=10>A B C D E F G H I J K L M N O P Q R S T U V W </FONT></FONT></H6>
</CENTER><CENTER>
<H6>
<FONT FACE="Courier New"><FONT SIZE=10>A B C D E F G H I J K L M N O P Q R S T U V W </FONT></FONT></H6>
</CENTER><CENTER>
<H6>
<FONT FACE="Courier New"><FONT SIZE=10>A B C D E F G H I J K L M N O P Q R S T U V W </FONT></FONT></H6>
</CENTER><CENTER>
<H6>
<FONT FACE="Courier New"><FONT SIZE=10>A B C D E F G H I J K L M N O P Q R S T U V W </FONT></FONT></H6>
</CENTER>
</body>
</html>
Der folgende Beitrag wurde am 28. 05. 1999, 08:58 Uhr von Thomas J.S. veröffentlicht.
Hallo Hendrik!
> Vieleicht kann jemand das script brauchen oder mir nen Tip zur vereinfachung geben.
Zumindest die viele »style = "position:absolute; top:100px; left:100px; visibility:hidden;"« könntest du durch eine 'class' Angabe ersetzen
.feuer { position:absolute; top:100px; left:100px; visibility:hidden; }
<div id="feuer000" class="feuer">....</div>
würde den Code auch schon verkleinern.
Grüße
Thomas
© 1998-2013 SELFHTMLImpressumSoftware: Classic Forum 3.4