2011-04-05 83 views
1

我有一個Web應用程序,它接收來自客戶端的變量並生成一個docx文件,然後將其返回給客戶端。我的Java端工作正常,當我將響應寫入客戶端的控制檯時,我可以看到一堆二進制文件,但客戶端將不會按照我希望的方式以ms-word打開此響應。我已經將ContentType設置爲application/vnd.ms-word,將Content-Disposition設置爲附件並指定了文件名,但沒有運氣。 任何人都知道問題可能是什麼?在javascript中從返回的輸出流中打開Docx文件

dojo.xhrGet({ 
    url : "file.docx", 
    content : { 
     ... 
    }, 
    load : function (response, ioArgs) { 
     console.log("Successful xhr - Response:", response); 
     window.open(response); 
     return response; 
    }, 
    error : function (response) { 
     ... 
    } 
}); 

回答

1

我最終使用了dojo.io.iframe.send()。我碰到的一個問題是,iframe不能自行解析,阻止未來的iframe被執行。如果在調用dojo.io.iframe.send()之前存在,我檢查以前的iframe並調用iframe.cancel()。