Sunday, December 13, 2009

How to create a Loading Indicator...

How to create a Loading Indicator...
CJ recently asked how to implement a loading indicator to hide the page layout changing regions into tab panels on my post Tabbed Regions in Oracle APEX using Ext JS.
While I use Ext JS to do it on my demo, here is how to do it using plain old javascript:
  1. Create a div element which has width and height 100% at the beginning of your page.
  2. Include an animated gif in a floating div to make it look like something is happening.
  3. Include the rest of your page and javascript below the div.
  4. Delete the div and image after a short delay using some javascript at the end of the page.
And here's the example html:
<html lang="en-au">
  <title>Page loading indicator</title>
  <!-- standard stylesheets -->

<style type="text/css">
/*Loading Indicator*/


#loading .loading-indicator{
  font:bold 13px tahoma,arial,helvetica;

  <script type="text/javascript">
      function removeElementById(el) {
          var node = document.getElementById(el);
          if (node) {
      function removeLoading() {

  <div id="loading-mask" style=""></div>
  <div id="loading">
    <div class="loading-indicator"><img src="" width="32" height="32" style="margin-right:8px;" align="absmiddle"/>Loading...</div>

  <!-- include everything, including scripts after the loading indicator -->

  <p>Here is some content that will appear when the loading indicator has been removed.</p>

<script type="text/javascript">


Peter said...

Very nice simple loading indicator. I also created a loading page that also disables the webpage while loading. See the example here:

Cj (Bar Staff) said...

Hi Mark,

Thanks very much for the example, I did finally manage to the ExtJS method working, similar to the way you have used it on your site.

I do have another question for you though, regarding ExtJS ItemSelectors in ApEx. Have you ever managed to get this working? I can get it working in standalone HTML, but as soon as I put the code into an ApEx page I get an error "this[name] is null". This is true in FF and IE6+, however Chrome does allow it to work!

I was using the example ItemSelector/MultiSelect code from the ExtJS Examples. Very strange, but I have a funny feeling it may be conflicting with something in the seeded ApEx Javascript.

Any ideas would be much appreciated as I have spent the last few days pulling my hair out over this!



Mark Lancaster said...


Haven't played with ItemSelectors.

Would have to see your code to offer any suggestions. If you put up a demo on the Apex site happy to look at it.

Cj (Bar Staff) said...

Hi Mark,

I have created an example on

If you look at it in Chrome first, you will see it displays correctly and works exactly as expected. If you view it in FireFox, only the multiselector is displayed and the error "this[a] is null" is returned by FireBug. Viewing in Internet Explorer shows neither the ItemSelector or the MultiSelector.

If you take a look at you will see the exact same code, outside of Apex works perfectly with all of the above browsers...

Very very strange, but any insight you may be able to give me would be greatly appreciated.

Many Thanks


Cj (Bar Staff) said...

Apologies, the link to the ExtJS example outside of ApEx was incorrect in my post. The correct link is:

Anonymous said...

Hi - I've tried this example, however some APEX items (Select List, Shuttle) are not being hidden while my loading indicator is shown though the rest of my page is hidden.

Any suggestions?

Thanks Brian

Mark Lancaster said...

Hi Brian

If you have items showing through it could be:
- the loading mask is not the first element
- you are using absolute positioning for your items

If you set up a test example, I could check it out.