JSFiddle - React, Tailwind, and code Playground
by Vladymyr Shevchuk
HTML
<html>
<head><title>MAIN WINDOW/TAB</title></head>
<body>
<h1>MAIN WINDOW/TAB</h1>
<div class='status'><h2>Events:</h2></div>
<hr/>
<button class='check-child-window'>Check child window status</button>
<button id="show">Open win</button>
</body>
</html>
JavaScript
show.addEventListener('click', () =>{
var win = window.open('http://google.com', '', 'width=200,height=50,left=200,top=50');
win.addEventListener('load',() => {
document.querySelector('.status').innerHTML += '<p>Child was loaded!</p>';
});
win.addEventListener('unload',() => {
console.error('unloaded');
});
});
function getChildWindowStatus() {
if (win.closed) {
return 'Child window has been closed!';
} else {
return 'Child window has not been closed!';
}
}