lundi 21 octobre 2019

how to wait for webpage to load

From my webapp, I am opening a new window and on that, after I click on a button it leads me to another page. I need to get the url of that page. I tried the following :

    var win = window.open(this.url, "_blank", "location=yes");
    try {
        win.addEventListener('beforeload', function(){
        console.log("it worked!!!!");
        console.log(win.location.href);
        });
    } catch (e) {
        console.log(e);
    }

I also tried replacing 'beforeload' with 'load' 'loadstart' and 'loadstop' but in any case, console log isn't showing any of those logs.

Can anyone tell me what I'm doing wrong/how I can solve this?

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire