使用Internet Explorer使用URL从服务器下载Excel文件时出现问题
我的PHP脚本上有以下代码
echo "<script>
window.location='http://localhost/complaint/export/export_complaint.xls';
</script>";
当我使用Chrome作为浏览器时,这个脚本可以创建自动下载操作,但不能在Internet Explorer中工作
我使用Internet Explorer 9
如果对此问题有任何建议,请告知。非常感谢!
如果不需要用javascript
进行重定向,可以用PHP
进行重定向,如下所示:
header("Location: http://localhost/complaint/export/export_complaint.xls")
对此使用jQuery
在jQuery中:
$('a#someID').attr({target: '_blank',
href : 'http://localhost/complaint/export/export_complaint.xls'});
每当单击该链接时,它都会在新的选项卡/窗口中下载该文件。