使用Internet Explorer下载文件时如何不打开文件对话框中的打开按钮

时间:2023-01-27 11:54:08

I have java code through which i set content type of excel and send it to browser. when ever it is downloaded using IE it shows open file dialogue which has OPEN,SAVE,CANCEL button. I need to avoid this OPEN button and only show SAVE & CANCEL button, how to do this java. I googled and found info that if we set meta type of contect in IE for download-option as noOPEN then this might be achieved; But i am not getting how to do this using java.

我有java代码,通过它我设置excel的内容类型并将其发送到浏览器。当它使用IE下载时,它显示打开文件对话框,其中有OPEN,SAVE,CANCEL按钮。我需要避免这个OPEN按钮,只显示SAVE&CANCEL按钮,如何做这个java。我用谷歌搜索并发现信息,如果我们在IE中设置元类型的竞争下载选项为noOPEN,那么这可能会实现;但我不知道如何使用java来做到这一点。

2 个解决方案

#1


0  

in java you can use

在java中你可以使用

response.setHeader("X-Download-Options", "noopen");

this code for hide open button.

这个代码用于隐藏打开按钮。

#2


0  

You can either render it inline by setting proper header

您可以通过设置正确的标题来内联呈现它

"content-disposition", "inline;filename=somefile.someExt"

or you can make it like attachment

或者你可以使它像附件

"content-disposition", "attachment;filename=somefile.someExt"

in which case browser has its own way to prompt user, you can't change it [unless your browser provides some sort of setting that your client can set]

在这种情况下,浏览器有自己的方式来提示用户,你不能改变它[除非你的浏览器提供客户可以设置的某种设置]

#1


0  

in java you can use

在java中你可以使用

response.setHeader("X-Download-Options", "noopen");

this code for hide open button.

这个代码用于隐藏打开按钮。

#2


0  

You can either render it inline by setting proper header

您可以通过设置正确的标题来内联呈现它

"content-disposition", "inline;filename=somefile.someExt"

or you can make it like attachment

或者你可以使它像附件

"content-disposition", "attachment;filename=somefile.someExt"

in which case browser has its own way to prompt user, you can't change it [unless your browser provides some sort of setting that your client can set]

在这种情况下,浏览器有自己的方式来提示用户,你不能改变它[除非你的浏览器提供客户可以设置的某种设置]