views:

51

answers:

2

I want to let the user click on a file (let's say a .doc link) in the browser and it will open the native desktop application (microsoft word in this case).

And when the user saves the document it will be saved in the web.

Is there a way doing this with Javascript/HTML 5 or does the user have to download the file to be able to open it with the native application?

+1  A: 

It is not possible to save back to your site unless the client application specifically supports it.

SLaks
You mean in this case the browser?
never_had_a_name
No; I mean the editor.
SLaks
+2  A: 

If you provide a link to this file on your page:

<a href="http://example.com/foo.doc"&gt;Open foo.doc</a>

it will be opened with the default application associated with this extension on the user computer.

If you want it to open inline inside the browser without any popup dialogs you could try setting the Content-Disposition HTTP header on the server: Content-Disposition: inline;filename=foo.txt. Of course the client application must have a plugin version which works with the browser and is capable of opening files inline (this is the case for example with Adobe Acrobat Reader).

As far as the second part of your question is concerned, there's absolutely nothing in the HTTP protocol specification allowing you to do this, so in order to achieve it it needs to be something custom-made. The client program needs to be able to talk to the server and send the modified version of the file back.

Darin Dimitrov
It is so sad that this is not easily possible... A simple "save handler URL" system that the local app (or the OS) uploads changed files back to could have fundamntally changed the way CMSs work (people being able to use their favourite apps to edit online content)
Pekka
@Pekka, no, that's a huge security issue. Please let's leave client applications run in a sandbox and never allow them sending anything back.
Darin Dimitrov
@Darin this *could* be implemented securely, say through a one-time upload token, or additional authentication... Not much different from any other web request really
Pekka
@Pekka, it's different than an ordinary web request because an ordinary web request cannot read files on your client computer while a browser plugin can.
Darin Dimitrov
@Darin no, what I mean is have a convention to 1. Download the file and store it locally 2. Open it locally e.g. using Word or OpenOffice or whatever 3. After exiting the local app, have the changed file be uploaded back to an upload handler (as a normal HTTP file upload) instead of it vanishing in the temp files folder (as is the case now).
Pekka
@Pekka. So with Darin's solution above, even if the file is opened with the native application it's pointless because the file is in the local temp folder after he has saved it right? Doesn't HTML5 fix this somehow?
never_had_a_name
No; HTML5 does not change this.
SLaks
@ajsie what @SLaks says. And nope, AFAIK there is nothing in HTML 5 to remedy this, either - it has local storage functions but they are for storing data from the web site in a local cache
Pekka