Browser opening text/xml in external program

孤者浪人 提交于 2019-12-12 04:47:59

问题


Is there a smart way to - from a browser - open hrefs to text files and XML files in an external program. My target platform is Win32 so preferably I'd have the files open in the default editor for it (as set in explorer.exe).

The solution must work in Firefox. It's a bonus if it works in IE and Crome.

My html is generated from a local developer database for files on disk. I.e. hrefs look like this: 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).

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.

Edit: is it possible in Javascript, anyone?


回答1:


To force the browser of the user to download a file instead of viewing it, you could add the following line to the HTTP response header:

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



回答2:


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.




回答3:


I am no html expert, but maybe you should just change the link from a href to a download. Textfiles i.e. should then be opened with notepads.




回答4:


It does not seem possible to solve (easily). I give up.



来源:https://stackoverflow.com/questions/1394684/browser-opening-text-xml-in-external-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!