js实现自动关闭当前页面,没有系统提示

    let time = document.getElementById("time");
	let n = 5;
	time.innerHTML = n;
	setInterval(function () {
		n--;
		time.innerHTML = n;
		if (n < 1) {
			window.open('','_self');
			window.close();
		}
	},1000)

使用以上代码即可实现5秒后自动关闭当前页面;如果不加上这一句window.open('','_ self'); 系统会弹框提示是否允许关闭。

欢迎大家一起交流vx:leecac

猜你喜欢

转载自blog.csdn.net/joyvonlee/article/details/84334709