Try using Jquery
First create a div element and assign an ID to it. I have assigned ID as "dvLoading". This div element will be used to show the loading icon.
Now create a style which will be applied to the div element. Basically, this CSS style will set the div position in the middle of the page and also assign width and height. And the background of the div will be an loading gif image.
background:#000 url(images/loader.gif) no-repeat center center;
margin: -25px 0 0 -25px;
Now, comes the jQuery part. The div element will be always visible but we need to hide it as soon as our page is loaded completely. In this case, we can't use $(document).ready() to show the loading div. Read here why? Therefore, we need to use window.load event to hide the loading div element. Remember to put this code before closing head tag.