PDA

View Full Version : variation on random image script


g00fy
02-13-2003, 10:22 AM
hi to all,

i have written a script based on a random image script to display a random html page inside an iframe marquee

it doesnt work though :(

can any1 offer suggestions ?


<script language="JavaScript">
var fileNum = 5 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (fileNum-1) * randomnumber) + 1 ;
files = new Array
files[1] = "http://www.ninemsn.com.au"
files[2] = "http://www.microsoft.com"
files[3] = "http://www.codingforums.com"
files[4] = "http://javascriptkit.com"
files[5] = "http://mandrakelinux.com"
var randFile = files[rand1]
</script>


and its called with

<iframe id="ticker_bottom" src="' + randFile + '" width="190" blah.. blah.. blah..>



thanx to all

kind regards,

g00fy

Ökii
02-13-2003, 12:54 PM
<script language="JavaScript">
files = new Array();
files[0] = "http://www.ninemsn.com.au";
files[1] = "http://www.microsoft.com";
files[2] = "http://www.codingforums.com";
files[3] = "http://javascriptkit.com";
files[4] = "http://mandrakelinux.com";

var fileNum = files.length;
var randomnumber = Math.round(Math.random()*filenum) ;
document.write('<iframe id="ticker_bottom" src="' + files[randomnumber] + '" width="190" blah.. blah.. blah..>');
</script>

flytyped - should work though.

ez4me2c3d
02-13-2003, 12:58 PM
you are putting the code in the header section right?
you are writting that iframe line with JS right?

this works<html>

<head>

<script language="JavaScript">
files = new Array;
files[1] = "http://www.ninemsn.com.au.com";
files[2] = "http://www.microsoft.com";
files[3] = "http://www.codingforums.com";
files[4] = "http://javascriptkit.com";
files[5] = "http://mandrakelinux.com";
randomnumber = Math.round((Math.random() * 4) + 1);
var randFile = files[randomnumber];
</script>


</head>

<body>

<script>document.write('<iframe id="ticker_bottom" src="' + randFile + '" width="690" height="600">no frame support</iframe>');</script>

</body>

</html>EDIT: posted while i was coding, oh well

g00fy
02-13-2003, 01:03 PM
thank you for pointing out my stupidity :o

i wasnt calling it using js ...hmmmm....



thanx to all


regards,

g00fy