Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Can JavaScript Close This Window?

0
Posted

Can JavaScript Close This Window?

0

Can JavaScript Close This Window? How to Tell if the Current Window (or Tab) was Opened From JavaScript One of the rules on how JavaScript interacts with the web browser window is that JavaScript is only allowed to close a browser window if that window was opened by JavaScript. If the particular browser window was already opened by your visitor before they can to your site then you are not allowed to close their browser window. The only browser that disregards this rule and will allow a browser to close a window that it didn’t open is Internet Explorer. Even that browser doesn’t just allow your JavaScript to close web browsers indiscriminantly though. If the browser window you are trying to close in IE is not one that your JavaScript opened then your visitor will see a confirmation dialog asking them to confirm if they will allow your script to close their browser. If they deny the request then their browser window stays open exactly the same as happens with all browsers except for Int

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.