/    Sign up×
Community /Pin to ProfileBookmark

SetTimeout not Delaying a Function Start

Sorry so basic. I just can’t figure out why this is (not) happening in IE 6.0 (the only browser I have tried it on). I am trying to delay a function. SetTimeout executes the function and passes its parameters fine, but there is no delay. I added the following as the first function in a javascript file:

[COLOR=DarkRed]function p4hOpacity(p4hDelay,zxcm,zxcsrt,zxcfin,zxcd,zxcstp){
setTimeout(zxcEleOpacity(zxcm,zxcsrt,zxcfin,zxcd,zxcstp),p4hDelay);
}[/COLOR]

I call it from inside my HTML file by:

[COLOR=DarkRed]<body onload=”p4hOpacity(3000,’clover’,1,100,100,50);”>[/COLOR]

=No anticipated 3-second delay.

Yet it calls the zxcEleOpacity function fine and fades in the image, just as it did before I added the delay function.

The code I added the function to was from vwphillips (thanks), found at the bottom of thread:

[COLOR=DarkOliveGreen]http://www.webdeveloper.com/forum/showthread.php?t=97595&highlight=image+fade[/COLOR]

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@CharlesSep 10.2006 — See http://www.w3schools.com/htmldom/met_win_settimeout.asp . You are passing as the first parameter to setTimeout what ever is returned by the function call zxcEleOpacity(zxcm,zxcsrt,zxcfin,zxcd,zxcstp).
Copy linkTweet thisAlerts:
@mousebearauthorSep 10.2006 — Obviously I'm new at this. I looked at the link. That shows a method. Is setTimeout both a Method and a Function? I have tried lots of perumations:

function p4hOpacity(p4hDelay,zxcm,zxcsrt,zxcfin,zxcd,zxcstp){

setTimeout("zxcEleOpacity(zxcm,zxcsrt,zxcfin,zxcd,zxcstp);",p4hDelay);

}

function p4hOpacity(p4hDelay,zxcm,zxcsrt,zxcfin,zxcd,zxcstp){

setTimeout("zxcEleOpacity(zxcm,zxcsrt,zxcfin,zxcd,zxcstp)",p4hDelay);

}

function p4hOpacity(p4hDelay,zxcm,zxcsrt,zxcfin,zxcd,zxcstp){

window.setTimeout("zxcEleOpacity(zxcm,zxcsrt,zxcfin,zxcd,zxcstp);",p4hDelay);

}

function p4hOpacity(p4hDelay,zxcm,zxcsrt,zxcfin,zxcd,zxcstp){

window.setTimeout("zxcEleOpacity(zxcm,zxcsrt,zxcfin,zxcd,zxcstp)",p4hDelay);

}

function p4hOpacity(p4hDelay,zxcm,zxcsrt,zxcfin,zxcd,zxcstp){

this.setTimeout("zxcEleOpacity(zxcm,zxcsrt,zxcfin,zxcd,zxcstp);",p4hDelay);

}

function p4hOpacity(p4hDelay,zxcm,zxcsrt,zxcfin,zxcd,zxcstp){

this.setTimeout("zxcEleOpacity(zxcm,zxcsrt,zxcfin,zxcd,zxcstp)",p4hDelay);

}

The example in the w3schools link was inside the HTML file. I could try that, but that's really not where I'd like to put it. I'd like to call this from lots of pages by putting it in the .js file
Copy linkTweet thisAlerts:
@felgallSep 11.2006 — The way that you need to code it is:

this.setTimeout("zxcEleOpacity("+zxcm+","+zxcsrt+","+zxcfin+","+zxcd+","+zxcstp+")",p4hDelay);
×

Success!

Help @mousebear 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 6.1,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...