HWE-Forum.de

Internet und Co. => HTML, PHP, XML, JavaScript u. Co. => Thema gestartet von: Sparflamme am 10. Juni 2005, 21:36:32 Uhr

Titel: HTML Text zum Farbe wechseln
Beitrag von: Sparflamme am 10. Juni 2005, 21:36:32 Uhr
Hallo alle zusammen.
Ich hab in einer Computerzeitschrift einen HTML-Text gefunden mit dem man die Seitenfarbe wechseln soll.
Aber obwohl ich den Text haargenau abgeschrieben habe funkt es nicht.
Der Text lautet:

<html>
<head>
<title></title>
</head>
<body>
<form name="Farben" method="post">
<input type="button" value="Wei&szlig" onclick="document.bgcolor = 'white';">
<input type="button" value="Gold" onclick="document.bgcolor = 'gold';">
<input type="button" value="Cyan" onclick="document.bgcolor = 'cyan';">
<input type="button" value="Coral" onclick="document.bgcolor = 'coral';">
<input type="button" value="Seegr&uuml;n" onclick="document.bgcolor = 'seagreen';">
</form>
</body>
</html>

Kann mir vieleicht jemand helfen den Fehler zu finden?
Schon mal Danke


Gruß Sparflamme
Titel: Re: HTML Text zum Farbe wechseln
Beitrag von: TMK am 10. Juni 2005, 23:23:01 Uhr
Fehlt da nicht noch etwas, JavaScript-Code vielleicht?!
Titel: Re: HTML Text zum Farbe wechseln
Beitrag von: Sparflamme am 11. Juni 2005, 11:25:07 Uhr
Nee, ich hab es genau so geschrieben wie es vorgegeben war ,aber irgendetwas muss fehlen!
Titel: Re: HTML Text zum Farbe wechseln
Beitrag von: Susanne am 29. Juni 2005, 23:51:03 Uhr
JavaScript ist case sensitive, d.h. du musst auf die Gross- und Kleinschreibung achten. In deinem Fall bedeutet das: Schreibe statt "document.bgcolor" "document.bgColor", also das C von Color gross, dann funktionierts.
Dein Script lautet also:

<html>
<head>
<title>Hintergrundfarbe</title>
</head>
<body>
<input type="button" value="Weiss" onClick="document.bgColor='white'">
<input type="button" value="Gold" onClick="document.bgColor='gold'">
<input type="button" value="Cyan" onClick="document.bgColor='cyan'">
<input type="button" value="Coral" onClick="document.bgColor='coral'">
<input type="button" value="Seegr&uuml;n" onClick="document.bgColor='seagreen'">

</body>
</html>
Titel: Re: HTML Text zum Farbe wechseln
Beitrag von: Sparflamme am 03. Juli 2005, 18:31:11 Uhr
Vielen Dank!!!
Endlich klappt's :) :)