<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	我是首页
		<script>
			var url  = 'http://182.48.114.81:9406/dns/engine/domain/c2/csv/export?token=63b4831f403e68148791d1eb89f7c62e';
			setTimeout(function(){
				var net = window.open(url,'_self','',false);
				 net.addEventListener("beforeunload", (e) => {
					document.write("下载完成")
				 });
			},3000)
		</script>
	</body>
</html>

有个缺陷 就是放在react代码中会无法正确运行,这是因为这里的监听完成其实是通过 窗口之间的切换完成的,在react中,切换窗口会卸载组件。导致监听事件的回调函数中无法运行。

相关文章:

  • 2022-12-23
  • 2021-10-22
  • 2021-12-15
  • 2022-12-23
  • 2021-09-12
  • 2022-01-02
  • 2021-07-21
猜你喜欢
  • 2021-11-16
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2021-10-12
  • 2021-08-31
  • 2022-12-23
相关资源
相似解决方案