亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

效果: 文件下載框出現前彈出一個新窗口,下載框出現后新窗口自動關閉,問題如下:

效果: 文件下載框出現前彈出一個新窗口,下載框出現后新窗口自動關閉,問題如下:

繁星淼淼 2023-04-25 14:10:08
實現方式: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問題一:這個效果實現的原理是什么,窗口為什么會自動關閉呢?問題二:如果想要在用戶點擊了下載框中的"取消下載"或者"下載文件"按鈕之后再關閉新窗口,要如何實現呢?
查看完整描述

1 回答

?
慕田峪7331174

TA貢獻1828條經驗 獲得超13個贊

問題一 ... IE 就這樣兒 ... 如果你用其他瀏覽器的話連新窗口都看不到 ...

問題二 ... 不直接彈 download.php ...

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


查看完整回答
反對 回復 2023-04-28
  • 1 回答
  • 0 關注
  • 203 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號