473,216 Members | 1,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,216 software developers and data experts.

Why it does not give me timeout?

QA
Array.prototype.shuffle= function(times){
var i,j,t,l=this.length;
while(times--){
with(Math){
i=floor(random()*l);j=floor(random()*l);}
t=this[i];this[i]=this[j];this[j]=t;
}
return this;
}
var st=[
"http://javascript.internet.com/img/image-cycler/01.jpg",
"http://javascript.internet.com/img/image-cycler/02.jpg",
"http://javascript.internet.com/img/image-cycler/03.jpg",
"http://javascript.internet.com/img/image-cycler/04.jpg"
]
st.shuffle(200);

function donothing () {return true;}

for(j=0;j<st.length;j++){

setTimeout('donothing()', 2000);
//rImage.src = st[j];
//rText.value = st[j];
document.write (st[j]);
}

**************************************
I want to display them every 2 second. After everything is displayed it then
stops.
But it does not give me the 2s delay. It displays everything once.
Jul 23 '05 #1
3 1422
"QA" <QA@alexa.com> skrev i melding
news:7%*****************@news04.bloor.is.net.cable .rogers.com...
I want to display them every 2 second. After everything is displayed it then stops.
But it does not give me the 2s delay. It displays everything once.


Try using setInterval.
setTimeout is a method for setting a one shot timer.

Oeyvind
http://home.online.no/~oeyvtoft/ToftWeb/
Jul 23 '05 #2
QA wrote on 10 sep 2004 in comp.lang.javascript:

function donothing () {return true;}

for(j=0;j<st.length;j++){

setTimeout('donothing()', 2000);
document.write (st[j]);
}

**************************************
I want to display them every 2 second. After everything is displayed
it then stops.
But it does not give me the 2s delay. It displays everything once.


Because you are doing nothing once.

If you would de setInterval you would be doing nothing [as advised
elswhere] every two seconds, which is an improvement but does not help,
as you want something done, as I presume.

SetTimeout() and set()interval start a seperate process after the stated
amout of miliseconds, they do not "wait" the script for that in their
place.

Furthermore, using document.write() after setup time will destroy the
page INCLUDING the javascript itself.

============================================

Try this code as a seperate HTML file

<div id='myDiv'>Start:<br></div>

<script type='text/javascript'>
var j=0;
myFunction();

function myFunction(){
d = document.getElementById('myDiv');
d.innerHTML+= j++ + "<br>";
if (j<30) setTimeout('myFunction()',500);
};
</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #3
JRS: In article <7%*****************@news04.bloor.is.net.cable.rog ers.c
om>, dated Fri, 10 Sep 2004 06:40:03, seen in news:comp.lang.javascript,
QA <QA@alexa.com> posted :
Array.prototype.shuffle= function(times){
var i,j,t,l=this.length;
while(times--){
with(Math){
i=floor(random()*l);j=floor(random()*l);}
t=this[i];this[i]=this[j];this[j]=t;
}
return this;
}


That's not a good way to shuffle; you should read the newsgroup FAQ, and
<URL: http://www.merlyn.demon.co.uk/js-randm.htm>.

Also, l is a poor choice of identifier, at least in News; it cal look
too much like 1.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chris Tanger | last post by:
Context: C# System.Net.Sockets Socket created with constructor prarmeters Internetwork, Stream and TCP everything else is left at the default parameters and options except linger may be changed...
2
by: Lars Netzel | last post by:
There's a setting in the IIS where I have set Enabled Session Timeout to 20 minutes Then there's a setting in the WebConfig file.. <sessionState mode="InProc"...
5
by: Robert | last post by:
Rather than setting by session I would like to configure the DB as read uncommitted. Thanx Advance.
11
pbmods
by: pbmods | last post by:
A somewhat obscure hack has emerged recently that is an offshoot of the now-infamous XSS. It is known as Cross-Site Request Forgery, or XSRF for short. XSRF is a form of temporary identity theft...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.