The code is as follows:
<script type="text/javascript"> function closeIt() { window.opener = ''; window.open('http://www.baidu.com'); window.open('', '_self'); window.close(); } self.setInterval("newTime()", 1000) var t = 4; function newTime() { if (t > 0) { t = t - 1; document.getElementById("txtTime").value = t } else if (t <= 0) { closeIt(); } else { closeIt(); } } </script>
Related articles:
Click the return button to close the current page and window in WeChat, Alipay and Baidu Wallet
JS summary of several ways to close the current page (window)
JS code that automatically jumps or closes the current page after a specified time