Popup After Submit. Display a loading window or please wait

35,648

You could show an element over the page when they click it, and then it will go away by itself upon navigating to the other page.

JavaScript:

function showLoading() {
    document.getElementById('loadingmsg').style.display = 'block';
    document.getElementById('loadingover').style.display = 'block';
}

HTML/CSS:

<style type="text/css">
      #loadingmsg {
      color: black;
      background: #fff; 
      padding: 10px;
      position: fixed;
      top: 50%;
      left: 50%;
      z-index: 100;
      margin-right: -25%;
      margin-bottom: -25%;
      }
      #loadingover {
      background: black;
      z-index: 99;
      width: 100%;
      height: 100%;
      position: fixed;
      top: 0;
      left: 0;
      -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
      filter: alpha(opacity=80);
      -moz-opacity: 0.8;
      -khtml-opacity: 0.8;
      opacity: 0.8;
    }
</style>

<div id='loadingmsg' style='display: none;'>Redirecting, please wait...</div>
<div id='loadingover' style='display: none;'></div>
<form action='' method='post' onsubmit='refreshpage();showLoading();'> 
   <input name='refresh' type="image" src="images/Next-Page-Button.gif" height="60" width="173" border="0" value='Refresh'> 
</form>

You can change the loading message to whatever you wish for it to say, of course.


Edit:

Just add the onclick event to the <li> like:

<li onclick="showLoading()">
   <a href="facebook.php">
      <img src="images/logos/facebooklikeicon.png" height="25" border="0" /> Earn Coins Facebook 
   </a>
</li>

Make sure you have the other HTML, CSS and JavaScript above this for the function to work.

Share:
35,648
Tahoe Cale
Author by

Tahoe Cale

Updated on July 05, 2022

Comments

  • Tahoe Cale
    Tahoe Cale almost 2 years

    Here's my script:

    <form action='' method='' onsubmit='refreshpage();'>
    <input name='refresh' type="image" SRC="images/Next-Page-Button.gif" HEIGHT="60" WIDTH="173" BORDER="0" value='Refresh'>
    </form>
    

    I want it when the user clicks the "next page" button a loading or please wait will pop up because it takes over 30 sec for the next page and I want the members to know the site is working, but also make the popup go away after the page is loaded.

    Also if you want to see the button in action my site is www.socialmedianetworkexchange.com and it's when you click the "earn facebook likes" button.