I have a JavaScript event listener function that waits for a user to click on any link then shows a loading box then progresses onto next page.
If a user then clicks the back button it still shows the loading box? Is there a way I can remove it without having to force refresh?
function loading_show() {
document.getElementById("loading").removeAttribute("style");
}
// Function to add event listener to t
function load() {
var el = document.getElementsByTagName("a");
for (var i = 0; i < el.length; i++)
{
el[i].addEventListener("click", loading_show, false);
}
}
function init() {
// quit if this function has already been called
if (arguments.callee.done) return;
// flag this function so we don't do the same thing twice
arguments.callee.done = true;
// do stuff
load();
};
var _timer = setInterval(function() {
if (/loaded|complete/.test(document.readyState)) {
clearInterval(_timer);
init(); // call the onload handler
}
}, 10);
PS. I'm developing for a mobile environment and I don't wish to use jQuery so don't suggest it please.