在浏览器中强制Mime类型(使用Javascript)

时间:2022-10-22 15:07:37

[I imagine that this is impossible due to security concerns, but:]

[我认为由于安全问题,这是不可能的,但是:]

Is it possible to force the browser to handle a file with a certain mime type without controlling the server? I'm serving up files from file:// (on the client's machine itself) and I'd like to get text files to open in whatever their associated text editor is.

是否可以强制浏览器处理具有某种mime类型的文件而无需控制服务器?我正在从file://(在客户端的机器本身上)提供文件,我想在任何相关的文本编辑器中打开文本文件。

Note: Firefox just opens the file for viewing, which is not the desired behavior. I've tried changing the file extension even to something unknown, which does not help.

注意:Firefox只是打开文件进行查看,这不是所需的行为。我已经尝试将文件扩展名更改为未知的内容,这没有用。

1 个解决方案

#1


Nope, this is impossible, except maybe with IE and an ActiveX, but I seriously suggest you not to use it.

不,这是不可能的,除了可能使用IE和ActiveX,但我认真建议你不要使用它。

#1


Nope, this is impossible, except maybe with IE and an ActiveX, but I seriously suggest you not to use it.

不,这是不可能的,除了可能使用IE和ActiveX,但我认真建议你不要使用它。