首页 > 文件下载框出现前弹出一个新窗口下载框出现后新窗口自动关闭的问题

文件下载框出现前弹出一个新窗口下载框出现后新窗口自动关闭的问题

实现方式:
download.php

		$outputFileName = "test.xls";
		header("Content-Type: application/force-download");
		header("Content-Type: application/octet-stream");
		header("Content-Type: application/download");
		header('Content-Disposition:inline;filename="' . $outputFileName . '"');
		header("Content-Transfer-Encoding: binary");
		header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
		header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
		header("Pragma: no-cache");

index.html

<html>
<head>
	<script type="text/javascript">
		window.open('download.php');
	</script>
</head>
<body>
	test
</body>
</html>

test.xls

效果:
文件下载框出现前弹出一个新窗口,下载框出现后新窗口自动关闭

问题一:这个效果实现的原理是什么,窗口为什么会自动关闭呢?

问题二:如果想要在用户点击了下载框中的"取消下载"或者"下载文件"按钮之后再关闭新窗口,要如何实现呢?


问题一 ... IE 就这样儿 ... 如果你用其他浏览器的话连新窗口都看不到 ...

问题二 ... 不直接弹 download.php ...

location.href 到 download.php 然后 window.close() ...

【热门文章】
【热门文章】