293
Views
4
Comments
How to close a windows tab?
Question


I have issues trying to implementing a logic to close a broswer's tab.

People say I should use a RunJavaScript action and type "window.close()" but that is not working.

I've set the button to Ajax Submit and validation to (none) but it also didn't work.


2019-05-22 11-30-09
Marcelo Ferreira

Hi Miguel,

Did you check the solutions in this post.

Regards,

Marcelo

UserImage.jpg
Miguel Manríquez

Marcelo Ferreira wrote:

Hi Miguel,

Did you check the solutions in this post.

Regards,

Marcelo


Hey Marcelo, 

Yeah I've tried those.

I've read that you can't close a broswer tab using the javasript "window.close()"

if you didn't open it previously using "window.open()"

2025-07-02 19-21-41
Carla Ribeiro da Fonseca

Hi Miguel,

As you already figured out, yes, you can't close tabs using JavaScript.

If you try something as simple as placing a link in your page pointing to #, and with this properties:

which generates this HTML:

which should close the tab when clicked, doesn't do anything.

The reason for this is that, and I'm oversimplifying this, you can only use scripts to close script-closable windows, and generally speaking, windows opened by the user aren't script-closeable.

See more here: https://www.w3.org/TR/html51/browsers.html#dom-window-close

2020-02-28 09-46-54
Eduardo Jauch

Hi, 

Maybe this would work (couldn't test)? 

Execute the following JavaScript:

window.open('','_self').close();

Edit. Sorry, this is what is in the post pointed by Marcelo. 

But the idea is really this one. The behaviour probably depends on the browser...

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.