Check if page was loaded after button is clicked

0

I have a button that calls other 4 buttons via jquery, each button opens a new tab and is in load state until the pdf is downloaded automatically, I need to verify that this page has finished loading to call the other buttons. Any suggestions?

function gerarTodosRelatorios(){    

 jQuery('.button1').on('click', function (e) {
     e.preventDefault();

     var target = jQuery(".button2");
     var target2 = jQuery(".button3");
     var target3 = jQuery(".button4");
     var target4 = jQuery(".button5");


     target[0].click();
     target2[0].click();
     target3[0].click();
     target4[0].click();
 });}
    
asked by anonymous 29.11.2016 / 20:25

1 answer

1

I do not know exactly how you are opening the tabs, but I think you need to keep the tab reference open and call the other tab onload it.

For example:

var aba= window.open('http://stackoverflow.com/', '_blank');
if (aba) {
    //navegador permitiu a abertura
    aba.onload(function(){
    //chamar aba 2

    });
} else {
    //Navegador bloqueou !
    alert('Bloqueado pelo bloqueador de popup');
}

that whereas the tab you say is a browser tab, if it is an HTML tab as a bootstrap of life, just use onload on it

    
29.11.2016 / 20:31