简体   繁体   中英

Force a download of a text file in IE7 using javascript

Saw a similar question at 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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