![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| 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 |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: Apr 2007
Posts: 9
OS: XP
|
Javascript randNumber problem
So I am trying to get a page to reload after a random amount of time from 10 to 30 seconds. It only reloads after 27 seconds for some reason. I also suck at javascript so help would be nice. :)
Code:
<script language="JavaScript1.2">
var randNumber = Math.round(Math.random()*20)+10;
</script>
<body onLoad=window.setTimeout("location.href='Loader.html'",Javascript:randNumber)>
</body>
|
|
|
|
| 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) |
|
Mentor, Analyst - Security Team
Join Date: May 2006
Location: Oregon
Posts: 2,503
OS: MacOS X, Debian, OpenBSD, Windows
|
Re: Javascript randNumber problem
I see nothing wrong with the code per-se except that setTimeout uses milliseconds instead of seconds. You'll need to multiply your final number by 1000 to get your 10-30 seconds.
__________________
The chance to begin again in a golden land of opportunity and adventure. Need HijackThis help? Please read MicroBell's Five Step Process before posting.
Please donate and help keep this site free to all. ![]() UNITE/ASAP: Proud member since 2006 |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: Sep 2004
Posts: 302
OS: Vista (on Laptop) WinXP Pro SP3 (on Desktop)
|
Re: Javascript randNumber problem
If you're really unsure of what's going on (maybe the randNumber is returning a similar value a couple of times in a row) print out to the screen what is returned by that randNumber.
__________________
AMD X2 5000+ Black w/ XFX GeForce 8200 MoBo 4GB OCZ DDR2 RAM 3/4 of a TB of data storage between 2 HDD's (no RAID) |
|
|
|
![]() |
| Thread Tools | |
|
|