0

I want to apply the keyboard shortcut Ctrl+W (closes a browser tab) on an asp.net button. When I click on the asp.net button, it should work like the above controls. Is it possible? And if it is, from where can I get the code for Ctrl+W(close a browser tab).

window.close() won't work to close a browser's tab.

Precise Tech
  • 173
  • 1
  • 9
Abdul
  • 2,002
  • 7
  • 31
  • 65
  • How you come to know that it is nearly useless? – Amit Jan 27 '15 at 12:34
  • @Amit `window.close()` does not work on the current window if it is invoked from a script (it only works in the console, and on other windows you have opened) http://stackoverflow.com/questions/19761241/window-close-and-self-close-do-not-close-the-window-in-chrome – meskobalazs Jan 27 '15 at 12:37
  • You have not specified your problem is with specific browser? Is it? It might be bug or something wrong with the code. Do not assume. https://productforums.google.com/forum/#!topic/chrome/GjsCrvPYGlA – Amit Jan 27 '15 at 12:44
  • It is not working anymore, because Chrome has actually fixed a long standing bug. – meskobalazs Jan 27 '15 at 12:53

1 Answers1

0

Simply put: it won't work, because you cannot close the current page with JavaScript (well, you can do it from your own developer console, but not from a script). Please take a look at this question for details: window.close and self.close do not close the window in Chrome

Community
  • 1
  • 1
meskobalazs
  • 15,741
  • 2
  • 40
  • 63