views:

666

answers:

1

Saw a similar question at http://stackoverflow.com/questions/349067/download-a-file-using-javascript but this one is specific to IE and I'm using extjs and alfresco (opsoro). I can get a download prompt for text files fine in Opera, Chrome, and Firefox, but not IE.

Below is a list of what I've tried so far, which all work on other browsers except IE7.

document.location = downloadLocation;

window.open(downloadLocation,'Download');

location.href = downloadLocation;

When downloading other mimetypes (csv, xls), they download fine using any of the methods mentioned above.

+2  A: 

You may need some help from the backend. Instead of serving the file statically, the backend app can load and serve the file contents with a content disposition header. That is guaranteed to invoke a download.

Content-disposition: attachment; filename=hello.txt

I don't know how you could do it with Alfresco, though.

Edit: Wait! Check this out: http://forums.alfresco.com/en/viewtopic.php?f=36&t=21356&p=70252

Ates Goral
Hi Ates, thank you for your quick reply! Unfortunately, that thread was started by me :( I came on SO hoping that maybe I could get around to force the download strictly using javascript.On a side note, perhaps I am using the wrong prop key in Alfresco? <prop key="txt">application/octetstream.txt+text</prop <prop key="txt">application/download.txt+text</prop> <prop key="txt">application/vnd.txt+text</prop> <prop key="txt">application/vnd.txt/text</prop> <prop key="txt">application/vnd.txt</prop>
Snowright
It can't be done in JavaScript. In addition, you must pass the ‘Content-Disposition: attachment’ header or IE may incorrectly ‘content-sniff’ and choose to view the file as another filetype if there are ‘magic words’ like HTML tags in it.
bobince