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

based on some actions on the page, I want to inform the user of a warning (that is .. your resume has been loaded.), and I want to close this window when the user clicks on it in this warning box. I want to do this using the alert method, not the confirmation method in javascript. why, because the alert method gives the only option β€œok”, where when the confirmation method gives β€œyes or no.” can anyone help me.

+2
source share
1 answer

Just put the statements one by one:

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

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

+5
source

Source: https://habr.com/ru/post/1209307/


All Articles