Random .swf on refresh

This is a discussion on "Random .swf on refresh" within the JavaScript Forum section. This forum, and the thread "Random .swf on refresh are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 19th, 2007, 09:46
Reputable Member
Join Date: Sep 2007
Location: UK
Age: 42
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
Random .swf on refresh

Code: Select all
<script language="JavaScript">

// Generate a Random Number
var randomnumber = Math.round(Math.random()*8);

// Select a movie and execute the corresponding function
if (randomnumber == 1)

{movie1();}

else if (randomnumber == 2)

{movie2();}

else if (randomnumber == 3)

{movie3();}

else if (randomnumber == 4)

{movie4();}

else if (randomnumber == 5)

{movie5();}

else if (randomnumber == 6)

{movie6();}

else if (randomnumber == 7)

{movie7();}

else {movie8();}


//Functions to write out the correct flash movie resource.

function movie1(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" 

codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" width=\"600\" height=\"100\"><param name=movie 

value=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie1.swf\"><param name=quality value=high><embed src=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie1.swf\" quality=high 

pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" 

width=\"600\" height=\"100\"></embed></object>")
}

function movie2(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" 

codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" width=\"600\" height=\"100\"><param name=movie 

value=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie2.swf\"><param name=quality value=high><embed src=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie2.swf\" quality=high 

pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" 

width=\"600\" height=\"100\"></embed></object>")
}

function movie3(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" 

codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" width=\"600\" height=\"100\"><param name=movie 

value=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie3.swf\"><param name=quality value=high><embed 

src=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie3.swf\" quality=high 

pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" 

width=\"600\" height=\"100\"></embed></object>")
}

function movie4(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" 

codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" width=\"600\" height=\"100\"><param name=movie 

value=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie4.swf\"><param name=quality value=high><embed 

src=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie4.swf\" quality=high 

pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" 

width=\"600\" height=\"100\"></embed></object>")
}

function movie5(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" 

codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" width=\"600\" height=\"100\"><param name=movie 

value=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie5.swf\"><param name=quality value=high><embed 

src=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie5.swf\" quality=high 

pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" 

width=\"600\" height=\"100\"></embed></object>")
}

function movie6(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" 

codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" width=\"600\" height=\"100\"><param name=movie 

value=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie6.swf\"><param name=quality value=high><embed 

src=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie6.swf\" quality=high 

pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" 

width=\"600\" height=\"100\"></embed></object>")
}

function movie7(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" 

codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" width=\"600\" height=\"100\"><param name=movie 

value=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie7.swf\"><param name=quality value=high><embed 

src=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie7.swf\" quality=high 

pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" 

width=\"600\" height=\"100\"></embed></object>")
}

function movie8(){
document.write("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" 

codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0\" width=\"600\" height=\"100\"><param name=movie 

value=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie8.swf\"><param name=quality value=high><embed 

src=\"http://www.wasteofinc.co.uk/jimi/Images/java/movie8.swf\" quality=high 

pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" 

width=\"600\" height=\"100\"></embed></object>")
}

</script>
My first problem :S

I have 8 swf files named movie1 to movie8, and this code, but it doesn't seem to be working.

Can anyone help me with this?
Reply With Quote

  #2 (permalink)  
Old Sep 19th, 2007, 10:47
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Random .swf on refresh

In your functions movie1() - movie8()

It looks like you have carriage returns in your document.write() data, you would need to remove all these even if they are in " quotes ".

It also helps to escape forward slashes in Javascript HTML output. eg <br \/>

All else seems okay though.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)

Last edited by Rakuli; Sep 19th, 2007 at 10:56. Reason: Added escaping info.
Reply With Quote
  #3 (permalink)  
Old Sep 19th, 2007, 12:48
Reputable Member
Join Date: Sep 2007
Location: UK
Age: 42
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Random .swf on refresh

yea had word wrap on in notepad! cheers works fine now, just need to link them all up.

I will post my code after, for future amateurs like me

thanks again
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to stop the browser refresh on clicking the webbrowser's refresh button ? camarun20 JavaScript Forum 3 Mar 18th, 2008 23:04
When Refresh go 1 again gncreditcards Web Page Design 2 Jan 30th, 2008 18:24
Logo changes on refresh Ross Web Page Design 10 Dec 13th, 2006 09:48
Meta refresh WebNinja Web Page Design 2 Nov 22nd, 2006 09:49
How to refresh XML data crashcup Other Programming Languages 3 Feb 6th, 2005 19:05


All times are GMT. The time now is 10:39.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43