實(shí)現(xiàn)方式: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問(wèn)題一:這個(gè)效果實(shí)現(xiàn)的原理是什么,窗口為什么會(huì)自動(dòng)關(guān)閉呢?問(wèn)題二:如果想要在用戶點(diǎn)擊了下載框中的"取消下載"或者"下載文件"按鈕之后再關(guān)閉新窗口,要如何實(shí)現(xiàn)呢?
效果: 文件下載框出現(xiàn)前彈出一個(gè)新窗口,下載框出現(xiàn)后新窗口自動(dòng)關(guān)閉,問(wèn)題如下:
繁星淼淼
2023-04-25 14:10:08