Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 06-23-2010, 11:49 AM Set Timeout Interval
Junior Talker

Posts: 2
Name: Jim
Trades: 0
Hi All:
I'm having a couple of issues and I'm not sure how to proceed and hoping someone can help...

I have an random image/link swap array which is working but only on subsequent visits or on refresh.

Here's that portion of the code:
function disp_links(number) {
for (i=1;i<=number;i++) {
var k = Math.floor(Math.random()*links.length);
document.write(links[k]);
}
}
function disp_links2(number) {...
function disp_links3(number) {...

And the Display code for that function:
disp_links(1);

What I'm try to make happen is after every 10 seconds the images/links change.

I've tried adding the following code to the calculation function which after the interval the images changed but the rest of site went away:
setTimeout((function (n) {
return function () {
disp_links(n);
};
})(number), 10000);

So I have two thoughts, its either the document.write() statement causing the rest of the site to disappear or set timeout statement should be down in the Display code.

I have exhausted my knowledge and could use some help...
JimEShoe is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-23-2010, 11:54 AM Re: Set Timeout Interval
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
http://www.elated.com/articles/javas...d-setinterval/
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-23-2010, 12:24 PM Re: Set Timeout Interval
Junior Talker

Posts: 2
Name: Jim
Trades: 0
Quote:
Originally Posted by chrishirst View Post

Ok so maybe setInterval()is the expression I need but where should it be placed, in function or down in the display?
JimEShoe is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Set Timeout Interval
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11550 seconds with 12 queries