0

The code i used in the javascript to close the window is as follows

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

in jsp

<a href="javascript:jscloseWindow()">Close</a> 

it's not working in chrome version 36.0.1985.143, it worked in previous chrome version, IE and in FF also. How can i fix it.

Please help me.

Thanks in advance.

1 Answers1

0

The chrome latest release has changed that functionlity as there has been several security issues because of that. You need to try like this:

chrome.windows.remove(integer windowId, function callback)

You can check here

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
  • This only works with Chrome extensions, which the OP does not seem to be using. – ComFreek Aug 20 '14 at 09:29
  • @ComFreek:- Do correct me if I missed something but I thought that OP wants to work it on Chrome as he mentioned:- `it's not working in chrome version 36.0.1985.143` – Rahul Tripathi Aug 20 '14 at 09:30
  • That's right, but that does not necessarily mean that the OP aims at developing a Chrome extension. Due to the mention of FF and IE, I *guess* that the OP is currently creating a normal website. – ComFreek Aug 20 '14 at 09:35
  • @ComFreek:- I do agree with that. But I thought that OP is facing the issue with Chrome only as it was there in the question title also. My bad! (So Should I delete my answer?) – Rahul Tripathi Aug 20 '14 at 09:42
  • No, I would at least wait for a comment by the OP. (I'm not a friend of deleting all irrelevant posts on SO, but your answer unfortunately won't help future visitors because `window.close()` - if used - always works in Chrome extensions.) – ComFreek Aug 20 '14 at 09:58
  • @ComFreek:- Yes I do agree with you but I think the Chrome extension may help others to identify it. Anyways i will wait for OP to respond. P.S. :- *May be I will get some downvotes for this :(* – Rahul Tripathi Aug 20 '14 at 10:00
  • i am not using any chrome extension, i am working for a company's website, previously it worked perfectly in all browsers. Recently i have update the chrome in my machine, after that the close hyper link is not working in only chrome browser. i need to fix this. i tried to implement chrome.windows.remove(integer windowId, function callback)...but didn't work..please help me. Thanks – user3780032 Aug 20 '14 at 14:11
  • I tried the kiosk mode also, the window.close() not working in chrome kiosk of the same version... – user3780032 Aug 20 '14 at 14:40
  • @user3780032 This is a [security feature](http://stackoverflow.com/a/19768082/603003). You cannot close windows which weren't opened by scripts. The only solution would be to write a Chrome extension, but that's probably overkill. – ComFreek Aug 20 '14 at 15:39
  • Ok..thank you sir..i will inform my users to not to use chrome..instead they can go with IE and FF. – user3780032 Aug 20 '14 at 16:40