This article example describes how to check whether to close the browser by js. Share it for your reference, as follows:
//Close the browser prompt message window.onbeforeunload = function (e) { e = e || window.event; var y = e.clientY; if (y <= 0//Click the close button of the browser or tab|| y >= Math.max(document.body ? document.body.clientHeight : 0, document.documentElement ? document.documentElement.clientHeight : 0)//Click the close button of the taskbar) { //IE and Firefox e.returnValue = "Confirm to refresh or close the browser window?"; } //Google return "Confirm to refresh or close the browser window?";}For more information about JavaScript related content, please check out the topics of this site: "Summary of JSON operation techniques in JavaScript", "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm techniques", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm techniques", "Summary of JavaScript traversal algorithms and techniques" and "Summary of JavaScript mathematical operations usage"
I hope this article will be helpful to everyone's JavaScript programming.