I display a loading screen after a button is clicked (which unhides the image), which then loads up another page. This works fine.
However, if the user clicks "Previous Page" and returns. My loading screen appears, so it is not hidden. It is fine if I manually refresh this page.
Here is my code. In html:
<input id="saveForm" class="btn btn-info" type="submit" name="submit" value="Submit" onclick="load()"/>
<script>
function load() {
document.getElementById('loader').style.display='block';
}
</script>
<img class="load_spinner" id="loader" style="display:none;"/>
In css:
.load_spinner {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
opacity: 0.5;
background: url(/static/img/Preloader_2.gif) center no-repeat #fff;
}
What should I do to hide the loading screen if the user returns?