Gernot Back: Zufallshintergrund

Beitrag lesen

Hallo Sebastian,

ok, dein quellcode ändert den hintergrund der GANZEN html seite. bei mir müsste sich aber nur der hintergrund der ersten zeile verändern:

Vorschlag:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Unbenanntes Dokument</title>

<script type="text/javascript">
<!--
var bgArray = new Array("bild1.jpg", "bild2.jpg");

function zufall() {
  do {
  zahl=parseInt(Math.random()*bgArray.length);
  } while((isNaN(zahl))||(zahl<0));

document.getElementById('ersteZeile').style.backgroundImage="url(" + bgArray[zahl] + ")";

}

window.onload=zufall;

//-->
</script>

</head>
<body>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">

<tr id="ersteZeile">
       <td style="height:113px">&nbsp;</td>

</tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>

Gruß Gernot