Here is a demonstration of my doubt
I couldn’t see any log on either of the windows and div “content-display” never changed
async function navigate() {
const myWindow = window.open("https://www.example.com", "", "width=100,height=100");
myWindow.onload = function() {
const innerContent = myWindow.document.body.innerHTML;
displayContent(innerContent);
};
}
function displayContent(content) {
console.log(content)
const contentDisplay = document.getElementById("content-display");
contentDisplay.innerHTML = content;
}
<button onclick="navigate()">Click it</button>
<div id="content-display"></div>