So as it has been discussed elsewhere, a window can be closed by js using window.close() only if it has been opened by a script.
I have a page that offers a button to open a discussion window. The discussion window opens to a new tab with window.open(). The discussion page has a button that calls window.close(), which closes the discussion window and takes you back to previous tab, so you can continue from where you left off.
The problem is that if someone takes a the url directly to the discussion window, the close button does not work.
Is there a way to detect if the window will be closable with window.close(), so I can show the button only if it will work?
window.closedo if it can't close the window? it might return undefined or give an error, you could check/catch thatvar chat = window.open()when you open it form the button, and then setchat = nullon close.if(chat !== null)then the window would have been opened via js