/    Sign up×
Community /Pin to ProfileBookmark

Problem with calling a function with setTimeout

I am calling ‘checkForProgressBar’ from a forms onsubmit. The below JS fails. But if I uncomment the ‘showProgressBar’ and comment out the setTimeout(… in checkForProgressBar the script works. I read somewhere that when using setTimeout that ‘this’ gets screwed up (something to do with scope). Is this the case here?

Any help appreciated!! Thanks

function checkForProgressBar() {
if (document.form1.fileName.value != “”) {
//showProgressBar();
setTimeout(‘showProgressBar()’,500);
};
};

function showProgressBar() {
myLightWindow.activateWindow({
href: ‘http://www.URLSOMEWHERE.com‘, // must be fully qualified URL!
title: ”,
width: 360, // must match the iframe in progBarFrame.asp
height: 60 // must match the iframe in progBarFrame.asp
});
};

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Aug 13.2007 — os the onsubmit actually firing completely [aka the page is being submitted]? If it is, that is the problem with your code.

Eric
Copy linkTweet thisAlerts:
@LeopardauthorAug 13.2007 — How would I test and/or fix/code around that?
×

Success!

Help @Leopard 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.18,
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,
)...