/    Sign up×
Community /Pin to ProfileBookmark

"Please Wait" window for long computations

Hello. I have created a DIV that is invisible by default. I want it to be visible at the beginning of the script and then hide at the end… This, however does not work:

[code]
<script>
document.getElementById(‘loading’).style.display=’block’;
…lots of javascript
document.getElementById(‘loading’).style.display=’none’;
</script>
[/code]

Because it seems like it starts trying to render the HTML before it shows the popup window.. So really, what happens is, it does what is between the block/none tags, and THEN renders the block/none afterwards.. Really fast-like. So you never see it…

So, instead, you get..

looooong paaaaaaause.. really fast: SHOW–HIDE.

Any way to work around that?

Any help is greatly appreciated.

dep

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinJan 26.2006 — computation versus display

it can probably compute the javascript inside the script faster than it can display, and so the computation grabs the available memory.

before your script, set a style:

<style>div{display:block}</style>

although the div will be 'block' anyway by default, so it's not really necessary, just hid it at the end
Copy linkTweet thisAlerts:
@depauthorJan 26.2006 — Well, it needs to be hidden until the computation is begun through the user interface. So this won't work, sadly. It needs to unhide, compute, then rehide.

dep
Copy linkTweet thisAlerts:
@depauthorJan 26.2006 — the way to fix it is to:

document.getElementById('loading').style.display='block';

setTimeout("thefunction()", 1);

document.getElementById('loading').style.display='none';

however, if this is already IN a function like this:

<i>
</i>function initLoad(window, element){
document.getElementById('loading').style.display='block';
setTimeout("thefunction()", 1);
document.getElementById('loading').style.display='none';
}

function thefunction(window, element){
alert(window + ' ' + element);
///Window and element are now lost.
}



How can I gracefully pass the window/element?
Copy linkTweet thisAlerts:
@CrazyMerlinJan 26.2006 — instead of using block/none, try using visibility (visible/hidden)
Copy linkTweet thisAlerts:
@depauthorJan 26.2006 — figured it out. thank you.
×

Success!

Help @dep 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.2,
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,
)...