How to close the current window in browser after clicking ok in the alert message?

alert, html, javascript

Solution

Just put the statements one after each other :

alert("ok");
window.close();

EDIT following Ankit's remark to OP : note that if you didn't open the window with Javascript yourself, you may not be authorized to close it depending on the browser.

Problem

based on some actions in a page , I want to give an alert message to the user (ie.. your resume has been uploaded.) like that and i want to close that window, when the user clicks okay in that alert box. I want to do this using alert method only instead of confirm method in javascript. why because alert method gives the only option "ok" where as confirm method gives " yes or no" .can anyone help me please.

Original source