[Javascript] Random file on page load... or at least that was the idea :(

McCoy, Thomas TMccoy at city.newport-beach.ca.us
Thu Oct 17 12:00:15 CDT 2002


Hello everyone!

I have a script which displays a random file when the page in loaded, but
sometimes it will display nothing.  The "nothing" error rate is not
consistent.  Any ideas?

Here is the script:
<script language="JavaScript">
<!-- Random Flash Player by Raphael Pirker (www.nr1webresource.com)

/* Let's make the Array of movies and the height and width. This is the only
block
you'll need to modify! Insert the path to the movies (you can add or remove
movies
as you wish!) and enter their height and width (in pixels) 
That's all! You're ready to roll! */ 

var movies = new
Array("graphics/peaceprize3.swf","graphics/peaceprize3.swf","graphics/peacep
rize3.swf","graphics/peaceprize3.swf","graphics/peaceprize3.swf","graphics/p
eaceprize3.swf","graphics/peaceprize3.swf","graphics/peaceprize3.swf","graph
ics/peaceprize3.swf")

// Nothing needs to be edited here! Change at your own risk... :-) 
len = movies.length;
today=new Date();
today=today.getTime()/10;
temp_number=today%len;
rnd = Math.round(temp_number); 

// Output into the source:
document.writeln('<EMBED src="'+ movies[rnd] +'" quality=high
TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_
Version=ShockwaveFlash" WIDTH="610" HEIGHT="200">'); 
document.writeln('</EMBED>'); 

// End of Script -->
</script>


See it in action (you'll have to keep refreshing the page to try and catch
an error) at:
http://www.city.newport-beach.ca.us/nbpl/greenroom/3/
I purposely made it load the same file randomly just to prove that it isn't
a corrupt Flash file.
 
 
Sincerely,
Thomas McCoy
The Supreme Javascript Lurker :0



More information about the Javascript mailing list