I have written a code in javascript :
When user click on a link, a loading image should be shown till next page loads.
It is working fine when user simply click on link, Loading image is visible till next page loads. But the problem is when a user clicks on link with CTRL button. target page open in new tab of browser and on page from where link was click, loading div continuously shown.
function ShowLoading(e) {
var div = document.createElement('div');
var img = document.createElement('img');
img.src = 'pageloaderB.gif';
img.style.cssText = 'border:0px';
div.innerHTML = "<b style=color:black;font-size:40px;font-family:calibri>Processing Request Please Wait</b><br><br><br>";
div.style.cssText = 'padding-top:200px;position: fixed; top: 0px; left: 0px; z-index: 5000; width: 100%; height:100%; text-align: center; background:white;opacity: .8;';
div.appendChild(img);
document.body.appendChild(div);
return true;
}
<a href="dashboard.php" class="ico1" onclick="ShowLoading()">Dashboard</a>
Javascript:
Please help me to close this. Either simple click or CTRL+Click, Loading div must be invisible when page loads completely.