In my next example, I have a button that calls through the window.location a page that takes a while to load. I'm trying to create a javascript code that loads the page before it's called and a "loading" label appears on the button page and then redirects to the other page
<label id="lbl"></label>
<input type="button" value="demo" id="btn_demo">
<script>
var btn = document.getElementById("btn_demo");
btn.onclick = function() {myFunction()};
function myFunction() {
document.getElementById("lbl").innerHTML = "LOADING!";
if page == "loaded" {
window.location.href="demo_load.htm";
}
//call page
}