![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Web Design & Programming Discussion of web design, and server-side & client-side scripting |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Dec 2005
Posts: 71
OS: WinXP home
|
a hand repairing some depricated javascript?
ok, i've been searching for some javascript which will load a random page on my site being visited. I'll explain why
Upon visiting the site, a .swf is shown which is kind've like a site intro thing. The thing is, i know from past experience seeing hte same .swf repeatedly can get VERY boring. Luckily i have a lot of the things :P problem is, i don't know how to dynamically switch between them. BUT Currently the way i load them is having my index.html redirect to the .swf file. With the swf redirecting to the main site when its clicked. My plan is to put some javascript into the html so instead of redirecting to a swf, file. It can redirect to a nmber of random swf's instead. Here is the code i found to do this, although it seems rather depricated / faulty If somebody could help by doing one of the following it'd be appreciated 1: repair the code 2: just find me some newer code which already works :P After i've got some working javascript i'm going to be moving the script into a .js file... i just prefer keeping my javascript in those things, makes it easier to edit at a later date --------------------CODE------------------- <html> <head> <title>page randomizer</title> <SCRIPT LANGUAGE="JavaScript"> var howMany = 3; // max number of items listed below var page = new Array(howMany); page[0]="http://www.danda-comics.co.uk/bgw/flash/flash.swf"; page[1]="http://www.danda-comics.co.uk/bgw/flash/lightning.swf"; page[2]="http://www.danda-comics.co.uk/bgw/flash/longflare.swf"; function rndnumber(){ var randscript = -1; while (randscript < 0 ¦¦ randscript > howMany ¦¦ isNaN(randscript)){ randscript = parseInt(Math.random()*(howMany)); } return randscript; } quo = rndnumber(); quox = page[quo]; window.location=page[ndnumber()]; </SCRIPT> </HEAD> <body> <p><center> If script doesn't work, return to:<br> <a href="http://www.bgw.danda-comics.co.uk/news.php">BGW.com</a> </center><p> </body> </html> ------------------------------------------------------------ like i said, any help appreciated.
__________________
Mobo: Asus Striker II Formula skt 775 Ram: 2x Corsair 2GB DDR2 PC2-6400 800MHz in dual channel Processor: intel q6600 quad core, 2.4ghz HD: 2 x Maxtor 500GB 1x Maxtor 1000gb PSU: Tagan 700w ATX2 Power Supply Sound: Asus soundcard that came with mobo GPU: 2x MSI 7900 GT/GTO 512mb memory in SLi |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#2 (permalink) |
|
Registered User
Join Date: Dec 2005
Posts: 71
OS: WinXP home
|
Re: a hand repairing some depricated javascript?
sorry no mater how much i'm looking an icannot see how to edit the above post...
I got some code which apparantly works, off of somebody on yahoo answers, however due to the way that site works... have the code was hidden... Well done yahoo. Here's the code i got from them, just trying to figur eout the mising bits -------------------------- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-... <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>page randomizer</title> <script type="text/javascript" language="JavaScript"> function init() { var howMany = 3; // max number of items listed below var page1 = new Array(howMany); page1[0] = "Page 1"; page1[1] = "Page 2"; page1[2] = "Page 3"; document.getElementById("output").innerH... += "Output = " + page1[rndnumber(howMany)] + " "; } //output.innerHTML function rndnumber(howMany) { var randscript = -1; while (randscript < 0 || randscript > howMany || isNaN(randscript)) { randscript = parseInt(Math.random()* 100) % howMany; document.getElementById("output").innerH... += "Rand = " + randscript + " "; } return randscript; } //window.location=page[rndnumber()]; </script> </head> <body onload="init()"> If script doesn't work, return to: <div id="output">a</div> </body> </html>
__________________
Mobo: Asus Striker II Formula skt 775 Ram: 2x Corsair 2GB DDR2 PC2-6400 800MHz in dual channel Processor: intel q6600 quad core, 2.4ghz HD: 2 x Maxtor 500GB 1x Maxtor 1000gb PSU: Tagan 700w ATX2 Power Supply Sound: Asus soundcard that came with mobo GPU: 2x MSI 7900 GT/GTO 512mb memory in SLi |
|
|
|
![]() |
| Thread Tools | |
|
|