0

Here I'm trying to close a single tab using javascript, but it doesn't work in chrome ver 38 (works fine in ver 28). But if I open a new window using javascript, then I can close this child window with javascript. I also need to close the parent window, please help me solve this issue. Below js code uses older version of chrome.

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

And i'm not able to use any extension like 'close kiosk'. My company won't allow me to do such things.

2
  • I'm on Chrome 38 and when I run that code in the console the window closes. What exactly is the error that you are getting? Commented Nov 20, 2014 at 7:29
  • I didn't get any response yet Commented Nov 20, 2014 at 7:48

1 Answer 1

1

You could try using:

self.close(); 

It works in Chrome, Safari, IE but not sure about Firefox.

Also, there's a new way to close windows using the new method window.close() in the dev version of Chrome: see here. But I recommend using the first method as it currently works.

Sign up to request clarification or add additional context in comments.

6 Comments

I just tried "window.open('', '_self', '');self.close();" but no use
If it's for your own use you can try to open up about:config and set allow_scripts_to_close_windows to true. Otherwise, you can just try to ues open(location, '_self').close(); --- It's not recommended but it should work.
about:config is only available in firefox. Correct me if i'm wrong
Yes, you're correct, i don't have a Chrome at work. Have you tried open(location, '_self').close() ?
yup, its just works only the older version of the chrome(ver 28)
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.