...

View Full Version : dynamic table background image



andyc209
03-14-2004, 07:35 PM
I have used this script below but all I get is a white screen. the paths to the images are correct.

Can anyone help me please?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>

<body>
<SCRIPT LANGUAGE="Javascript"><!--

var arr = newArray("graphics/main_img1.jpg","graphics/main_img2.jpg","graphics/main_img3.jpg");

var increment = Math.floor(Math.random() * arr.length);

//pre-load image
var img = new Image();
img.src=arr[increment];

window.onload=function(){
document.getElementById('tblID').style.background="white url("+img.src+") no-repeat fixed center"
}


//--></SCRIPT>
<table id="tblID">
<tr>
<td width="500" height="500"></td>
</tr>
</table>


</body>
</html>

Garadon
03-14-2004, 07:37 PM
I usually put a \ before a / in javascripts I believe

Willy Duitt
03-14-2004, 08:27 PM
newArray is two words.

eg:
This: arr = newArray
Should be: arr = new Array

.....Willy

andyc209
03-14-2004, 10:03 PM
thanks for the replys, it works now but my dhtml menu is not working. might be something to do with having 2 onloads now.

Thanks anway



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum