1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Violet_82
0

Ok I run a quick test to try to get this image thingy to work, but still no luck at all.
I attach the code, sure my javascript is dodgy...
test.htm page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">



<script type="text/javascript">
<!--
function swapImages()
{
var myImages = new Array("test1.jpg","test2.jpg","test3.jpg");



for (randomImage = Math.floor(Math.random()*myImages.length); randomImages<3; randomImages++)
{
document.write(myImages[randomImage]);
}
}
//-->
</script>

<title>Photography Home</title>

<link rel="stylesheet" type="text/css" href="containers.css">

</head>

<body id="page_body" onload="swapImages()">


<div class="wrapper"> <!-- MAIN CONTAINER -->

</div>




</body>

</html>

CSS containers.css:

@charset "utf-8";
* /* overall settings*/
{
margin:0;
padding:0;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
}

.wrapper /* main container */
{
width:900px;
min-height:600px;
/*background: #000000 url(test1.jpg) no-repeat;*/
}

Images attached, everything is the same folder
in my javascript I attempted to load a different image everytime the page is refreshed (now this is not what I eventually have but I suppose it is a good starting point, at least I try to understand a bit more about JS. Eventually I would like to add some jquery so that I can have a sort of slideshow, with images gradually disappearing evry 5-10 secs).
So I created a function swapImages() , copied the array elements in a variable, then the for loop should loop through the images and the document.write(myImages[randomImage]); should ideally display the images...but obviously that doesn't happen, anybody can give me a hand please?
thanks

Attachments test1.jpg 293.73 KB test2.jpg 354.76 KB test3.jpg 402.12 KB
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.