window.close() function doesn't work on RunJavaScript

Hi, all.

I'm trying to implement the button which makes the window close.

What I did is following.


 

When I click the close button, anything doesn't happen.

I coded "alert();" instead of window.close() as a test.

It worked.


What is the problem?

Hi,

I think window.close() will only work on page which are opened by script.

Regards.

I think that scripts can't close windows that they didn't initialize. You can look for the solutions on this thread to see if any of them can help you.

Prasad Rao wrote:

Hi,

I think window.close() will only work on page which are opened by script.

Regards.

When I tried on another app, this script worked.

I just opened the app from browser...


I really don't unserstand what the cause is...




Thank you.



Lucas Gonçalves Vilela Fernandez wrote:

I think that scripts can't close windows that they didn't initialize. You can look for the solutions on this thread to see if any of them can help you.

I even tried the "window.open('','_self').close()" but didn't work...


Thank you.


Hi,

Any of those options shouldn't work for security reasons. Some browsers open it a bit, like chrome, and let you close a window that was open by the same javascript. But this is not true for all the browsers, for example Firefox will only let you if you turn a setting on. You can read about it here.

Regards,

Marcelo