What i see in docs that if you open the tab manually using window.open
then you have option to close it.
openNewWindow() {
const newWindow = window.open('https://www.google.com/', 'hello');
setTimeout(() => {
newWindow?.close();
}, 100);
}
Playground Link: Playground
2
Answers
It depends on the internet speed. If opening a new window takes more than 100ms. The newWindow object is not yet initialized and newWindow?.close() will not be executed.
Your code seems to work with other URLs.
Try with
example.org
ordeveloper.mozilla.org
.Maybe
www.google.com
has a feature that prevents the window from being closed.