Load page before being called

2

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
 }

    
asked by anonymous 02.02.2016 / 14:18

1 answer

0

Would that be?

<script>
    var goTo = function(){
        document.getElementById("lbl").innerHTML = "LOADING!";
        window.location.href="demo_load.php";
    }
</script>

<label id="lbl"></label>
<input type="button" value="demo" id="btn_demo" onclick="goTo()">

demo_load.php:

<?php
//Apenas para simular um processamento
sleep(5);

echo 'vim';
    
02.02.2016 / 14:30