arsie
01-22-2005, 08:36 PM
Hey guys!
I am sort of in a dilemma here.
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta content="mshtml 6.00.2800.1264" name="generator" />
<title>Random Images</title>
<script type="text/javascript">
//<![CDATA[
var images=new Array();
images[0]="image_1.jpg";
images[1]="image_2.jpg";
images[2]="image_3.jpg";
images[3]="image_4.jpg";
images[4]="image_5.jpg";
images[5]="image_6.jpg";
images[6]="image_7.jpg";
images[7]="image_8.jpg";
images[8]="image_9.jpg";
images[9]="image_10.jpg";
var i=Math.floor(Math.random()*images.length);
function randomImage() {
document.getElementById("random").src=images[i];
}
onload=randomImage;
//]]>
</script>
</head>
<body>
<div>
<img id="random" alt="random image" src="" />
</div>
</body>
</html>
As you can see, this code is perfect for what I am attempting to do.
All I want is for a randomly chosin image to load on every refresh.
Here's the catch... with this script, everything works fine... that is, as long as the person viewing isn't blocking scripts.
When the viewer has scripts disabled, there will be no image shown. This is not good.
Is it possible to make a default image load just incase scripts are disabled?
I am sort of in a dilemma here.
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta content="mshtml 6.00.2800.1264" name="generator" />
<title>Random Images</title>
<script type="text/javascript">
//<![CDATA[
var images=new Array();
images[0]="image_1.jpg";
images[1]="image_2.jpg";
images[2]="image_3.jpg";
images[3]="image_4.jpg";
images[4]="image_5.jpg";
images[5]="image_6.jpg";
images[6]="image_7.jpg";
images[7]="image_8.jpg";
images[8]="image_9.jpg";
images[9]="image_10.jpg";
var i=Math.floor(Math.random()*images.length);
function randomImage() {
document.getElementById("random").src=images[i];
}
onload=randomImage;
//]]>
</script>
</head>
<body>
<div>
<img id="random" alt="random image" src="" />
</div>
</body>
</html>
As you can see, this code is perfect for what I am attempting to do.
All I want is for a randomly chosin image to load on every refresh.
Here's the catch... with this script, everything works fine... that is, as long as the person viewing isn't blocking scripts.
When the viewer has scripts disabled, there will be no image shown. This is not good.
Is it possible to make a default image load just incase scripts are disabled?