Java sript in eine externe CSS Datei einbauen?
So meine HTML Datei sieht so aus:
Und die design.js Datei:
Und alles in einem Ordner aber es funzt einfach nich.
Wo ist den der fehler?
Danke im voraus.
Gruß euer <Hoppel>
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>
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>
Wo ist den der fehler?
Danke im voraus.
Gruß euer <Hoppel>
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
daraus wird dann das hier
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);
}
außerdemJan500 hat geschrieben:das du die js zwar einbindest aber die functions nicht ausführst
- Jan500
- Ehemaliges Teammitglied
- Beiträge: 4199
- Registriert: 01.03.2003 21:32
- Wohnort: Hamburg
- Kontaktdaten:
jenachdem wann das ausgeführt werden soll
aber ich denke sobald die seite geladen ist also onload()
aber ich denke sobald die seite geladen ist also onload()
"Life begins at 40 Knots...!" 
kein (kostenlosen) Support per pn, mail, icq usw. | Kostenlosen Support gibt es hier im Forum!

kein (kostenlosen) Support per pn, mail, icq usw. | Kostenlosen Support gibt es hier im Forum!
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?
Hier ist der komplette Code.
Es geht nicht hab es auch schon aufm Server, warum geht es nich in einer seperaten Datei?
- Jan500
- Ehemaliges Teammitglied
- Beiträge: 4199
- Registriert: 01.03.2003 21:32
- Wohnort: Hamburg
- Kontaktdaten:
das hab ich dir doch oben geschrieben inkl link -.- alsobrain.exe muss bei dir schon ausgeführt und aktiv sein
"Life begins at 40 Knots...!" 
kein (kostenlosen) Support per pn, mail, icq usw. | Kostenlosen Support gibt es hier im Forum!

kein (kostenlosen) Support per pn, mail, icq usw. | Kostenlosen Support gibt es hier im Forum!