Seite 2 von 5
Verfasst: 11.06.2008 19:02
von Jan500
das ist ein beispiel wo das angewendet wird -.-
soll heißen das brauchst du nicht...
etwas html würde ich schon lernen (selfhtml ist dazu gut geeignet)
Jan
Verfasst: 11.06.2008 19:10
von <Hoppel>
So meine HTML Datei sieht so aus:
Code: Alles auswählen
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<title>Flying Rabbit</title>
<link rel="shortcut icon" href="bilder/favicon.ico">
<link rel="stylesheet" type="text/css" media="screen" href="design.css" />
<script src="design.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>
Und die design.js Datei:
Code: Alles auswählen
<script type='text/javascript'>
<!--
posx = 0;
posy = 0;
z = 0;
welle = 3;
wellen = -3;
z1 = -12;
function zeichneflagge(xpos, ypos, farbe, teil, index)
{
document.write("<div id='"+teil+index+"' style='position:absolute;top:"+ypos+"px;left:"+xpos+"px;font-family:webdings;font-size:12;color:"+farbe+"'>/</div>");
}
document.write("<div style='position:absolute'>");
for(z = 0; z < 14; z++)
{
zeichneflagge(posx + z*4, posy,"black","schwarz", z);
zeichneflagge(posx + z*4 - 6, posy+12,"red","rot", z);
zeichneflagge(posx + z*4 - 12, posy+24,"gold","gold", z);
}
document.write("<div id='wmtext' style='position:absolute;top:42px;left:0px;font-family:serif;font-size:12;color:black'>WM 2006</div>");
document.write("</div>");
function mauspos(e)
{
if (!e) {
posx = event.x;
posy = event.y - 30;
} else {
posx = e.pageX;
posy = e.pageY - 30;
}
}
function fahne()
{
for(z = 0; z < 14; z++)
{
schwarz = document.getElementById('schwarz'+z);
rot = document.getElementById('rot'+z);
gold = document.getElementById('gold'+z);
schwarz.style.top = ( posy + document.body.scrollTop + welle * Math.sin(z1 + z/wellen) ) + "px";
rot.style.top = ( posy + document.body.scrollTop + 12 + welle * Math.sin(z1 + z/wellen) ) + "px";
gold.style.top = ( posy + document.body.scrollTop + 24 + welle * Math.sin(z1 + z/wellen) ) + "px";
schwarz.style.left = ( posx + document.body.scrollLeft + z*4 ) + "px";
rot.style.left = ( posx + document.body.scrollLeft + z*4 - 6 ) + "px";
gold.style.left = ( posx + document.body.scrollLeft + z*4 - 12 ) + "px";
}
text = document.getElementById('wmtext');
text.style.left = ( posx + document.body.scrollLeft ) + "px";
text.style.top = ( posy + document.body.scrollTop + 42 ) + "px";
if(z1++ > 11)
z1 = -12;
setTimeout("fahne()", 40);
}
//-->
</script>
Und alles in einem Ordner aber es funzt einfach nich.
Wo ist den der fehler?
Danke im voraus.
Gruß euer <Hoppel>
Verfasst: 11.06.2008 19:13
von Jan500
das du die js zwar einbindest aber die functions nicht ausführst
Jan
Verfasst: 11.06.2008 19:13
von 4seven
Da die design.js schon eine javascript-datei ist, brauchst du die scriptanweisungen am anfang und ende nicht mehr. sonst wird nichts draus.
also das hier raus
Code: Alles auswählen
<script type='text/javascript'>
<!--
javascript-code
//-->
</script>
daraus wird dann das hier
Code: Alles auswählen
posx = 0;
posy = 0;
z = 0;
welle = 3;
wellen = -3;
z1 = -12;
function zeichneflagge(xpos, ypos, farbe, teil, index)
{
document.write("<div id='"+teil+index+"' style='position:absolute;top:"+ypos+"px;left:"+xpos+"px;font-family:webdings;font-size:12;color:"+farbe+"'>/</div>");
}
document.write("<div style='position:absolute'>");
for(z = 0; z < 14; z++)
{
zeichneflagge(posx + z*4, posy,"black","schwarz", z);
zeichneflagge(posx + z*4 - 6, posy+12,"red","rot", z);
zeichneflagge(posx + z*4 - 12, posy+24,"gold","gold", z);
}
document.write("<div id='wmtext' style='position:absolute;top:42px;left:0px;font-family:serif;font-size:12;color:black'>WM 2006</div>");
document.write("</div>");
function mauspos(e)
{
if (!e) {
posx = event.x;
posy = event.y - 30;
} else {
posx = e.pageX;
posy = e.pageY - 30;
}
}
function fahne()
{
for(z = 0; z < 14; z++)
{
schwarz = document.getElementById('schwarz'+z);
rot = document.getElementById('rot'+z);
gold = document.getElementById('gold'+z);
schwarz.style.top = ( posy + document.body.scrollTop + welle * Math.sin(z1 + z/wellen) ) + "px";
rot.style.top = ( posy + document.body.scrollTop + 12 + welle * Math.sin(z1 + z/wellen) ) + "px";
gold.style.top = ( posy + document.body.scrollTop + 24 + welle * Math.sin(z1 + z/wellen) ) + "px";
schwarz.style.left = ( posx + document.body.scrollLeft + z*4 ) + "px";
rot.style.left = ( posx + document.body.scrollLeft + z*4 - 6 ) + "px";
gold.style.left = ( posx + document.body.scrollLeft + z*4 - 12 ) + "px";
}
text = document.getElementById('wmtext');
text.style.left = ( posx + document.body.scrollLeft ) + "px";
text.style.top = ( posy + document.body.scrollTop + 42 ) + "px";
if(z1++ > 11)
z1 = -12;
setTimeout("fahne()", 40);
}
Jan500 hat geschrieben:das du die js zwar einbindest aber die functions nicht ausführst

außerdem
Verfasst: 11.06.2008 19:17
von <Hoppel>
wie führ ich die den aus?
Jetzt ist da nur das Bild aber die function wird nich ausgeführt
Verfasst: 11.06.2008 19:23
von Jan500
jenachdem wann das ausgeführt werden soll
aber ich denke sobald die seite geladen ist also
onload()
Verfasst: 11.06.2008 19:29
von <Hoppel>
http://www.kostenlose-javascripts.de/ja ... fahne.html
Hier ist der komplette Code.
Es geht nicht hab es auch schon aufm Server, warum geht es nich in einer seperaten Datei?
Verfasst: 11.06.2008 19:36
von Jan500
hast du denn den link von mir gerad gelesen? und auch ausprobiert bzw dich weiter in das thema reingelsen? denke nicht bei der kurzen zeit
Verfasst: 11.06.2008 19:39
von <Hoppel>
check es aber nicht, ich frag ja nur nachdem Befehl welchen ich ausführen muss um es zu machen?
Verfasst: 11.06.2008 19:43
von Jan500
das hab ich dir doch oben geschrieben inkl link -.- also
brain.exe muss bei dir schon ausgeführt und aktiv sein