Function windowClose()

I am trying to fire some javascript code to close the browser window when a button is clicked.
Here’s my setup:
Button config:
onclick

body config:
onclick body

When the page is on the server, the window does not close. What have I not done correctly?
Thanks.

Most modern browsers prevent you from closing windows with javascript that were not opened with JavaScript window.open("https://example.com") .

There are some “hacks” out there that get around this restriction.

I haven’t tried this, but opening a blank url first in the same tab or window, then closing is supposed to be a good work around

window.open("", "_self");
window.close();
2 Likes

I did not know that the browser behaves differently depending on how I access my home page. The button does not work when I access my web page through the URL that I right clicked from the index.html and copied from my server files (Copy URL).
index

However, if I access my page through a normal link, the close button works as intended. Woo hoo.

Thank you Doug. This was very helpful!