Php 如何使用url在Internet Explorer上下载Excel文件

Php 如何使用url在Internet Explorer上下载Excel文件,php,javascript,excel,internet-explorer,Php,Javascript,Excel,Internet Explorer,我在使用Internet Explorer使用URL从服务器下载Excel文件时遇到问题 我的PHP脚本中有下面的代码 echo "<script> window.location='http://localhost/complaint/export/export_complaint.xls'; </script>"; echo” 窗口位置http://localhost/complaint/export/export_complaint.xls


我在使用Internet Explorer使用URL从服务器下载Excel文件时遇到问题
我的PHP脚本中有下面的代码

echo "<script>
        window.location='http://localhost/complaint/export/export_complaint.xls';
    </script>";
echo”
窗口位置http://localhost/complaint/export/export_complaint.xls';
";
当我使用Chrome作为浏览器,但不在Internet Explorer中工作时,此脚本可以自动创建下载操作
我使用InternetExplorer9
如果对此问题有任何建议,请告知。非常感谢

为此使用jQuery

在jQuery中:

$('a#someID').attr({target: '_blank', 
                    href  : 'http://localhost/complaint/export/export_complaint.xls'});

无论何时单击该链接,它都会在新的选项卡/窗口中下载文件。

如果不需要使用
javascript
进行重定向,则可以使用
PHP
进行重定向,如下所示:

header("Location: http://localhost/complaint/export/export_complaint.xls")

type=“text/javascript”
属性添加到
script
tagThank@Ander2,当我下载Excel 2003格式时它可以工作,但对于Excel 2007仍然失败format@user1875301检查我的答案,它会工作使用
jQuery
下载文件这是一个简单的结论。谢谢@Ander2Hi Sumit,我非常感谢你的建议。非常感谢!但事实上,我是一个新手作为开发人员。我认为@Ander2的答案对我来说很简单。