/    Sign up×
Community /Pin to ProfileBookmark

script delay

Is there anyway I can put a delay on this script from running?

var refreshTime = 15000; // 15sec
function Ad() {
this.width = (arguments[0]!=null?arguments[0]:0);
this.height = (arguments[1]!=null?arguments[1]:0);
this.src = (arguments[2]!=null?arguments[2]:””);
this.href = (arguments[3]!=null?arguments[3]:””);
this.title = (arguments[4]!=null?arguments[4]:””);
}
function switchAd() {
c_ad=(c_ad+1)%ads.length;
document.getElementById(“adlink”).href=ads[c_ad].href;
document.getElementById(“adimg”).src=ads[c_ad].src;
document.getElementById(“adimg”).alt=ads[c_ad].title;
document.getElementById(“adimg”).title=ads[c_ad].title;
document.getElementById(“adimg”).width=ads[c_ad].width;
document.getElementById(“adimg”).height=ads[c_ad].height;
}

var ads = new Array()

// Ad 01___________
ads[ads.length]=new Ad(468, 60,
// src
http://ad.linksynergy.com/fs-bin/show?id=2ndrq7W2vFA&bids=85498.10000088&subid=0&type=4&gridnum=1“,
// href
http://click.linksynergy.com/fs-bin/click?id=2ndrq7W2vFA&offerid=85498.10000088&subid=0&type=4“,
// alt
“PennyTalk 468×60 v2 Intl”);

// Ad 02 ___________
ads[ads.length]=new Ad(468, 60,
// src
http://ad.linksynergy.com/fs-bin/show?id=2ndrq7W2vFA&bids=80489.10000025&subid=0&type=4&gridnum=1“,
// href
http://click.linksynergy.com/fs-bin/click?id=2ndrq7W2vFA&offerid=80489.10000025&subid=0&type=4“,
// alt
“Cheap Tickets Flights”);

var c_ad=Math.floor(Math.random()*ads.length);
if(c_ad==ads.length) cad–;

document.write(“<a target=’_blank’ id=’adlink’ href='”+ads[c_ad].href+”‘>”+
“<img id=’adimg’ border=’0′ src='”+ads[c_ad].src+”‘ alt='”+ads[c_ad].title+
“‘ title='”+ads[c_ad].title+”‘ width='”+ads[c_ad].width+
“‘ height='”+ads[c_ad].height+”‘></a>”);
window.setInterval(“switchAd()”, refreshTime);

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@JPnycMay 08.2005 — setTimeout('myFunction()', 5000);
Copy linkTweet thisAlerts:
@ranosbauthorMay 08.2005 — Okay, I fiqured that much but how would I use that, with this particular script?

It has 2 functions plus addtional scripting...
Copy linkTweet thisAlerts:
@JPnycMay 08.2005 — Put the delay on call of the 1st, and put the call for the 2nd in the 1st, if you can. If not, then put all the function calls in another function and delay that one.
Copy linkTweet thisAlerts:
@felgallMay 08.2005 — The script already has a 15 second delay between switching ads by calling [b]window.setInterval("switchAd()", refreshTime);[/b] so you only need to worry about whatever delay that you want in calling Ads() in the first place. So use:

var delayDisplay = 5000; // seconds * 1000
Ad();
setTimeout('Ads()',delayDisplay);


This will stop the first ad displaying for 5 seconds.

If instead you want to delay until the page finishes loading and then display the first ad then do this:

Ad();
window.onload = Ads;
Copy linkTweet thisAlerts:
@ranosbauthorMay 09.2005 — Where do I put this?

Ad();

window.onload = Ads;

The scripting is externally called within the body...

<script language="JavaScript1.2" src="java/banner_ads06.js">

</script>
×

Success!

Help @ranosb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...