for example, I'm running page "login.html", on which there are 2 buttons "yes" and "no", you click "no", the browser will automatically close. I hope to get help from people
Asked
Active
Viewed 265 times
0
-
Duplicate: http://stackoverflow.com/questions/3670475/close-window-in-javascript â LJá Apr 25 '13 at 02:45
-
may this help you : http://stackoverflow.com/questions/5455426/is-it-possible-to-close-a-browser-window-using-javascript â Aminesrine May 02 '13 at 20:02
1 Answers
1
Something like the following would work depending on your "input" methods
<input type="button" value="close window" onclick="window.close()"/>
But just to clarify the close method closes only windows opened by JavaScript using the open method. If you attempt to close any other window a confirm message is displayed, asking the user to choose whether the window is to be closed or not for obvious security reasons

Curtis Crewe
- 4,126
- 5
- 26
- 31
-
thank you for looking at my problem, but the problem is I want to shut down the browser if clicking "cancel" on login. Here is the first part of the code, I want to execute the command to close the browser instead of the "simpleForm.getForm (). Reset ();". So there is no real way: Code : buttons: [{ text: 'OK', handler:loginclick },{ text: 'Cancel', handler: function () { simpleForm.getForm().reset(); } }] }); â user2293157 Apr 26 '13 at 01:10