title: Load Image while page is loading in JSP
body: <p>I have been trying to display an image in while my page is loading. But as you can see in the screenshot that page is loading before the image. Probably because of sequence.</p>
  
  <p><img src="https://i.stack.imgur.com/ddZ5Q.png" alt="enter image description here"></p>
  
  <pre><code>    &lt;head&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=EDGE"/&gt;
      &lt;style&gt;
      div#loading {
          top: 200 px;
          margin: auto;
          position: absolute;
          z-index: 1000;
          width: 160px;
          height: 24px;
          background: url(/images/loadingM.gif) no-repeat;
          cursor: wait;
          }
      &lt;/style&gt;
      &lt;/head&gt;
  &lt;body&gt;&lt;div id="loading"&gt;&lt;/div&gt;&lt;/body&gt;
  </code></pre>
  
  <p>And at the bottom of the page I have used this script</p>
  
  <pre><code>window.onload = function(){ document.getElementById('loading').style.display='none';}
  </code></pre>
  
  <p>But my page is not loading before the content. So, in a nut shell I can't see loading image on page load.</p>