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:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* 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
Go Back   Tech Support Forum > Design Forum > Web Design & Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Web Design & Programming Discussion of web design, and server-side & client-side scripting

Reply
 
LinkBack Thread Tools
Old 07-07-2008, 07:51 PM   #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
wowfood is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
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

Old 07-07-2008, 08:49 PM   #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
wowfood is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
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 Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 12:42 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85