This article describes how JS implements the method of closing the current page without popping up a prompt box. Share it for your reference, as follows:
Close the current page and open a new page (no prompt)
function closeWinAndOpen(url) { var sWinName = "LR"+parseInt(Math.random() * 100000000);// Use random numbers to process WinName window.open(url,sWinName, 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes'); closeWin();}Close the current page:
function closeWin() { window.opener=null; window.open('','_self'); window.close();}Close the parent page:
The code copy is as follows: Response.Write("<script>window.top.opener=null;window.parent.close();</script>")
(window.top.close() works well)
Setting window.opener=null can not display: "The web page you are viewing is trying to close the window, whether to close the window?"
For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm skills", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm skills", "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.