Close window

Hi everyone,
I know this is a basic issue, but i am getting stuck with it!
How can i close the browser when logoff "link" is pressed?
I had tried to put some javascript as Window.close() but it didn't worked...
Thanks in advance for your answers :-)
João have you tried window.close()  (all lower case, javascript is case sensitive) on the onclick property?
Hi António and thanks for your reply,
I'd tryied this with the logout link:
- Added the extended property with name: onclick
- value: "window.close()" one time and "window.close();" another time
The logout link method is submit and the destination it is set to an action called logout and then redirects to the login webscreen
Booth times it executed the logout action and ignored the extended property...

Hello João,

after a small search around the webs, i found something that i will quote:

window.close @ MDN (Mozilla docs)

This method is only allowed to be called for windows that were opened by a script using the method. If the window was not opened by a script, the following error appears in the JavaScript Console: Scripts may not close windows that were not opened by script.

W3C norm on HTML5 agrees :

The close() method on Window objects should, if the corresponding browsing context A is an auxiliary browsing context that was created by a script (as opposed to by an action of the user), and if the browsing context of the script that invokes the method is allowed to navigate the browsing context A, close the browsing context A (and may discard it too).


So it seems that you can only close window using window.close() if that window was opened with

So, this is not a solution :(, but its something to look at, and probably change that application requirement.

Thank you all for your suggestions,
I guess I will have to try an workarround to solve this issue...

Thank you again for your support :-)
Hi guys,

Find attached an OML with a tiny 'home made' Javascript widget that has a delayed close of the screen.
Note that it uses a little 'trick' so the user will not be confronted with any close notes.

In the widget a tiny text note is done for Firefox in order to make this work.


Hi Eric,
Thank you for your help.
It works fine with IE but with Firefox i can't put it working...
I readed the Firefox note but i didn't understand it quite well.

Thanks a lot :-)

The firefox modification is essential in order to make this work under firefox.
The notes I put there assumed you to have somewhat more experience with firefox.

Let me elaborate the steps for you that are described in the widget:

1.input "about:config" to your firefox address bar and hit enter

2. Click the above button: probably stating something like "I promise to be careful"

3. Do yourself a favor and filter on "dom.allow_scripts_to_close_windows"

4. Make sure your "dom.allow_scripts_to_close_windows" is true

5. Now close Firefox and start it again.

That should do the trick.

As an example hereby my last image that shows a closed screen:



Hi Eric,
Indeed I haven't much experience configuring firefox, but after following your tips it is working with firefox too.

Thanks a lot for your support,
Best regards
You're welcome.

Have a good 2012 ;)
Thanks and for you too :-)
And a good 2012 for all the community :-)))))