Click to See Complete Forum and Search --> : Is possible??


muek
09-22-2003, 01:58 PM
Hi,

I'm try to make that when my page is load a random image appear, called screen1.jpg or screen2.jpg.

I try to make this by changing "scr=" but doesn't work

Can someone give me a hand??

Thanks in advance.

Here my code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

function test2()
{
var MAX = 2;
var index = Math.floor( Math.random()*MAX )+1;
var texto = "imagens/screen" + index + ".jpg";
document.write(texto);
return texto;
}
</script>

<body >

<img src="test2();" width="25%" height="25%">
</body>
</html>

Charles
09-22-2003, 02:10 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<head lang="en">
<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(this.length * Math.random())]}

bettie = ['http://www.bettiepage.com/images/photos/bikini/bikini1.jpg', 'http://www.bettiepage.com/images/photos/bikini/bikini2.jpg']
// -->
</script>
</head>
<body>
<script type="text/javascript">
<!--
document.write('<img alt="[Bettie Page]" src="', bettie.random(), '">')
// -->
</script>
<noscript><img alt="[Bettie Page]" src="http://www.bettiepage.com/images/photos/bikini/bikini1.jpg"></noscript>
</body>
</head>

muek
09-23-2003, 08:01 AM
Thanks