Hi window.location.href, using hidden Iframe and setting its source dynamically, setting return false; for onclick Nothing is working for IE. Basically, my dwr response generates a log file (foo.log) @business layer and it sends file name as response to dwr rpc request. Now I know the file name and its location I just want to download that file.(It works in FF not in IE).
I want save file popup.
My code snippet - On some button click -->
RemoteDWR.downloadLogs( id, function ( obj ) { var jsonObj = eval ( obj );//file name and it path window.location.href = jsonObj.object;// this redirect's to the file ( IE ) }); I used hidden Iframe and set its source on response but still it doesnt work in IE.
To cause a web browser to download a file that it would otherwise display inline, you must have the web server serve it with the header:
Content-Disposition: attachment
Nothing you can do on the client-side with iframes or JavaScript will affect this.
worked for me -- Need to write struts action - inputStream application/octet-stream attachment;filename=${fileName} 2048
and action class download examples http://jtute.com/codeDownload.html
Struts 2 Design and Programming: A Tutorial chapter 13 a, 13b will give you idea.
No other way we cant set header types in js. we have to action class which will set above mentioned properties.