From 1d5e225fd408908dde315e6a5cbc09c2b38c418a Mon Sep 17 00:00:00 2001 From: Yuri Iozzelli Date: Wed, 5 Oct 2022 12:25:47 +0200 Subject: [PATCH] Wait for login window to load before using it --- index.html | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index d71b42b..078eb97 100644 --- a/index.html +++ b/index.html @@ -91,15 +91,17 @@ window.networkInterface.listen = listen; loginElem.style.cursor = "pointer"; statusElem.style.color = "white"; - loginElem.onclick = async () => { + loginElem.onclick = () => { loginElem.onclick = null; statusElem.innerHTML = "Downloading network code..."; const w = window.open("login.html", "_blank"); - await up(); - w.document.body.innerHTML = "Starting login..."; - statusElem.innerHTML = "Starting login..."; - const url = await loginPromise; - w.location.href = url; + w.onload = async () => { + await up(); + w.document.body.innerHTML = "Starting login..."; + statusElem.innerHTML = "Starting login..."; + const url = await loginPromise; + w.location.href = url; + }; };