You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

6. June 2012, 18:49:42

kangarrou

Posts: 7

"window.close();" not working

As I said in the title "window.close();" is not working for me (XP SP3)

Someone knows if it's just me or maybe it's something blocked because of security issues?

6. June 2012, 20:51:31

kangarrou

Posts: 7

someone could please save this as test.html
<script>window.close();</script>

then open a empty tab an drag the file into it?

does it close?

7. June 2012, 01:38:54

Moderator

sgunhouse

Volunteer

Posts: 65165

In an empty tab? Of course not, there is no javascript environment for an empty tab. Rather, go to the address bar of this tab and type javascript:window.close(); into it. (Don't worry, you can reopen the tab from the closed tabs list.)

7. June 2012, 16:06:08

kangarrou

Posts: 7

Originally posted by sgunhouse:

In an empty tab? Of course not, there is no javascript environment for an empty tab. Rather, go to the address bar of this tab and type javascript:window.close(); into it. (Don't worry, you can reopen the tab from the closed tabs list.)



Empty or not empty, for me it doesn't close anyway

And I also tried avoiding url javascript because it uses to be more limited.

7. June 2012, 16:50:41

Moderator

sgunhouse

Volunteer

Posts: 65165

Didn't work anyway ... (Now that I'm actually using the beta to test it, instead of the stable version.)

7. June 2012, 17:42:27

kangarrou

Posts: 7

Originally posted by sgunhouse:

Didn't work anyway ... (Now that I'm actually using the beta to test it, instead of the stable version.)


Thanks a lot for the confirmation.

Would you mind trying something else?

If I open any link with Ctrl+Click (to have a fresh tab) and then use "javascript: window.close();", now it DOES work, so it seems that the problem is just for reused tabs

7. June 2012, 18:23:20

Opera Software

daniel

Mac product tester, Opera Software

Posts: 1257

The intended behavior here is changed in Opera 12.

window.close() can only be used to close windows opened from JavaScript.

7. June 2012, 18:32:38

kangarrou

Posts: 7

Ctrl+Click in a link is not a window opened from javascript, but it closes. (Nevermind)

Thanks anyway.

8. June 2012, 10:07:17

wardies

Posts: 140

Originally posted by daniel:

window.close() can only be used to close windows opened from JavaScript.


Thanks for the explanation; I can understand this behaviour from a security perspective and it's a nice feature.

However, is there going to be a workaround for the (presumably) thousands of workers who use Opera to access internal web applications? Those web applications have a Close [Esc] button on the login screen and the user is going to be clicking that button, hitting Esc and then calling their IT Support staff when it won't go away. Often they're running in full screen kiosk mode so they won't know they have to hit Alt+F4.

Are there any plans for a workaround, like an "Allow script to close main window" setting in Site Preferences -> Scripting?

8. June 2012, 14:22:16

kangarrou

Posts: 7

Originally posted by wardies:

Are there any plans for a workaround, like an "Allow script to close main window" setting in Site Preferences -> Scripting?


+1

8. June 2012, 15:52:03

moimadmax

Posts: 49

Maybe the extension behaviour change (see here) come from this change.

18. June 2012, 11:15:29

proxen

Posts: 6

I'm also waiting for a solution but in the meanwhile, due to Opera's limitation, I'll have to tell our users to use another browser (where it works without any problems) if they want to have this feature fully functional.

Forums » Opera for Windows/Mac/Linux » Beta testing (including snapshots and previews)