|
|
|
07/10/2005 - 21:30 (Category: Javascript) This script is helpful to produce random images in your web page. The script consists of two parts: the first one within the <head> section, and the other one within the <body> section. This script is compatible with Internet Explorer, Netscape 6, Mozilla, Safari, Opera. Part one within the <head> section of your page:
<script language="JavaScript" type="text/JavaScript">
<!--
function image() {
};
image = new image();
number = 0;
// imageArray
image[number++] = "<img src='http://www.wowarea.com/picture_1.jpg'>"
image[number++] = "<img src='picture_2.jpg'>"
image[number++] = "<img src='picture_3.jpg'>"
// Add here other pictures ....
increment = Math.floor(Math.random() * number);
// -->
</script>
Part two within the <body> section of your page (where you want the image to be displayed): <script language="JavaScript" type="text/JavaScript"> document.write(image[increment]); </script> The image() object is an array containing the picture links of your web site. Thanks to the random() method, random pictures will be available (by getting them from the image() object). The document.write method displays the chosen picture in your web page. Go back
DISCLAIMER: |
|