Ask coding questions

← Back to all posts
window.close not working
MikeJMS8910 (160)

So I have a code that opens up a tab and then once the tab has loaded it will close the tab. Here is the code -

let x = true;

while(x == true) {
let y = window.open("https://google.com")
y.onload = y.close()
}

What it does do is just open the tab up very fast but never close it. So why is it not working and how can I fix this?