This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaScript: "Wait while loading" message

 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to display a "Please wait while page loads" message. So I added a div with a loading message immediately underneath the opening body tag (in which init() is called)...

As is (without modifying the init function), the div displays as expected at the top of the page.

Next, I added the following to the page's init() function...

(Because I'm a JavaScript novice, I based this on an ancient example.)

These lines seem to be working correctly, because the div is now "hidden" when the page loads. The problem is that the div is not showing before its display is set to "none." Is there something "obvious" I'm missing here?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you place the script right after the div, of course it will not show because as soon as the div is done rendering, the JavaScript code is called and hides it.

You probably should be callig your code on the page load event





What is taking so long to run/render that you want to add this loading message?

Eric
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eric Pascarello:
...You probably should be callig your code on the page load event...

The code is inside the init() function, which is being called in the body tag with onload. Would this make a difference?

The page is an xml table of contents tree pulling its data from a Lotus Notes database. In some cases this is taking up to 10 seconds to load. (It's a lot of really messy stuff supplied by a vendor.)
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the data is being pulled on the server, than the wait message will not matter since the page does not get retured until the server is done procesing.

You would need to put the wait message before you make the request on the previous page OR you should use Ajax.

Eric
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eric Pascarello:
...You would need to put the wait message before you make the request on the previous page...

That makes sense. I'll look at that. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic