Reputation: 113
I am trying to add a page loading spinner when i click on a dsp(dynamic server pages) page link. I have tried onload and div functionalities as specified in other threads, but the spinner is coming just before the body of the page loads and is not fading out.
To be more clear, when i click on the link, there is a blank page till the page loads, and just before the body is being loaded on page, the spinner starts and remains on the page.
Could someone please help me where, when i click on the link, the spinner should be there until the service output(body) is displayed on the page.
Regards Harish
Upvotes: 1
Views: 394
Reputation: 3877
Create the loading spinner with just HTML and CSS. Load your javascript at the bottom of the page and in it select the spinner by id and hide it. This will ensure the spinner is shown as early as possible in the loading process and hiden/faded out after the page and javascript has been loaded.
If you are using jquery--
$("#spinner").fadeOut( "slow");
From your question it sounds like you are using javascript to show the spinner as well which is why it is being displayed just before the page finishes loading and not while it is loading.
EDIT: Here is a codepen with a working example.--
http://codepen.io/anon/pen/XKoqZq
I have hidden the rest of the page in the css with the display:none
property . This is optional but this makes the whole page show at once when the loading finishes.
Upvotes: 1