0

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?

Jonas Byström
  • 25,316
  • 23
  • 100
  • 147

4 Answers4

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>" 
Daan Bakker
  • 6,122
  • 3
  • 24
  • 23
0

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.

Mitchel Sellers
  • 62,228
  • 14
  • 110
  • 173
0

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.

RED SOFT ADAIR
  • 12,032
  • 10
  • 54
  • 92
  • I don't like the idea of people downloading local files from their C: to their C:. The idea was that they'd be able to edit their local files (using preferred editor) when clicked upon in the browser. – Jonas Byström Sep 08 '09 at 16:05
0

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

Jonas Byström
  • 25,316
  • 23
  • 100
  • 147