Click to See Complete Forum and Search --> : store result of a function


alvar
08-17-2003, 10:26 AM
i have put a script in my page to show a random image (below).

i have links that change that image to something appropriate to the link, question is, onMouseOut,

how can i return the image to the original randomly selected image?

thanx!

function check()
{
var img_name = new Array("....");

var l = img_name.length;

var rnd_no = Math.round((l-1)*Math.random());

var memory = document.thumb.src = img_name[rnd_no];


}

Charles
08-17-2003, 11:10 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<title>Example</title>
<script type="text/javascript">
<!--
Array.prototype.random = function () {return this[Math.floor(Math.random() * this.length)]}

url = ['http://www.bettiepage.com/images/photos/bikini/bikini1.jpg', 'http://www.bettiepage.com/images/photos/bikini/bikini2.jpg', 'http://www.bettiepage.com/images/photos/bikini/bikini3.jpg', 'http://www.bettiepage.com/images/photos/bikini/bikini4.jpg']
// -->
</script>

<img alt="[Bettie in a Bikini]" onmouseout="if (this.begin) this.src = this.begin" onmouseover="this.begin = this.src; this.src = url.random()" src="http://www.bettiepage.com/images/photos/bikini/bikini1.jpg">