473,403 Members | 2,323 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,403 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 1430
"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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.