 |
home
tutorials
random picture chooser
bitwise operators in java
email spam protection
tools
ping
http client info
links
download
contact
|
 |
 |
Random Picture Chooser
Press the reload-button of your browser to randomly change the following picture
(Usually, pressing the F5 key will also reload the page.):
The example above is accomplished with the following JavaScript code. This code
makes the browser to randomly insert one of 3 pictures at the location where the
code is placed. You can put this code to anywhere on a webpage. Just make sure
that the paths to the pictures are adjusted correctly.
<script language="javascript"><!--
//array with possible pictures
var pictures = new Array(
"picture1.jpg",
"picture2.jpg",
"picture3.jpg"
);
//write img-tag with random src-attribute to page
var rnd = Math.floor(Math.random() * pictures.length);
document.write('<img src="' + pictures[rnd] + '">');
//--></script>
|
|