简体   繁体   English

浏览器在外部程序中打开text / xml

[英]Browser opening text/xml in external program

Is there a smart way to - from a browser - open hrefs to text files and XML files in an external program. 是否有一种聪明的方法-从浏览器中打开href到外部程序中的文本文件和XML文件。 My target platform is Win32 so preferably I'd have the files open in the default editor for it (as set in explorer.exe). 我的目标平台是Win32,因此最好在默认编辑器中打开文件(在explorer.exe中设置)。

The solution must work in Firefox. 该解决方案必须在Firefox中有效。 It's a bonus if it works in IE and Crome. 如果它可以在IE和Cr​​ome中使用,则是一个奖励。

My html is generated from a local developer database for files on disk. 我的html是从本地开发人员数据库生成的,用于磁盘上的文件。 Ie hrefs look like this: file://c:/a/b/c.ext . 即href看起来像这样: file://c:/a/b/c.ext Currently, Firefox and IE show their built-in XML viewer, and god knows what Chrome is showing (looks like random XML excerpts to me). 目前,Firefox和IE显示其内置的XML查看器,而上帝知道Chrome显示的是什么(对我来说,看起来像是随机XML摘录)。

I don't know if this is of any relevance, but all hrefs are of type <map><area href/></map> (over an image) and not just simple <a href/> s. 我不知道这是否有任何意义,但是所有href都是<map><area href/></map> (在图像上),而不仅仅是简单的<a href/>

Edit : is it possible in Javascript, anyone? 编辑 :有可能用Javascript吗?

要强制用户的浏览器下载文件而不是查看文件,可以在HTTP响应标头中添加以下行:

Content-Disposition: attachment; filename="<file name.ext>" 

When you are dealing with links to files, you cannot change the launch application on the server side of things. 当处理文件的链接时,您无法在服务器端更改启动应用程序。 This would be a behavior that the user would need to configure on their side via the settings of their browser. 这将是用户需要通过其浏览器的设置在其侧面进行配置的行为。

I am no html expert, but maybe you should just change the link from a href to a download. 我不是html专家,但也许您应该将链接从href更改为下载。 Textfiles ie should then be opened with notepads. 然后应使用记事本打开文本文件,即。

It does not seem possible to solve (easily). 似乎不可能(轻松)解决。 I give up. 我放弃。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM