下面是test.html的一段代码,为什么执行test1(),提示下载excel文件,而test2()打开excelexport.php之后,没有提示保存就自动关闭了?
<input type="button" value="btn1" onclick="test1()"/>
<input type="button" value="btn2" onclick="test2()"/>
<script language="javascript" type="text/javascript">
function test1() {
window.open("excelexport.php");
}
function test2() {
window.setTimeout(test1,1);
}
</script>
excelexport.php的代码:
<?php
header("Content-Type:application/force-download");
header("Content-Type:application/vnd.ms-execl");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");
header('Content-Disposition:attachment;filename="charging.xls"');
header("Content-Transfer-Encoding:binary");
?>
--
FROM 219.159.77.*