Chciałbym dynamicznie utworzyć dokument za pomocą JavaScript, a następnie otworzyć ten dokument w Microsoft Word. czy to możliwe? Oto mój obecny kod:Używanie JavaScript do "tworzenia" dokumentu Microsoft Word
<html>
<head>
<title></title>
<script src="js/jquery-1.4.4.js" type="text/javascript"></script>
</head>
<body>
<div id="myDiv">The quick brown fox jumped lazly over the dead log.</div>
<script type="text/jscript">
var printWindow = window.open("", "Print", "width=800,height=400,scrollbar=0");
var printAreaHtml = $("#myDiv").attr("outerHTML");
printWindow.document.open("text/html", "replace");
printWindow.document.writeln("<html><head>")
printWindow.document.writeln("<meta HTTP-EQUIV='Content-Type' content='application/vnd.ms-word'>");
printWindow.document.writeln("<meta HTTP-EQUIV='Content-Disposition' content='attachment;filename=print.doc'>");
printWindow.document.writeln("</head>");
printWindow.document.writeln("<body>");
printWindow.document.write(printAreaHtml);
printWindow.document.writeln("</body>");
printWindow.document.writeln("</html>");
printWindow.document.close();
// printWindow.print();
</script>
</body>
</html>
Co próbujesz osiągnąć? –
Teoretycznie można utworzyć poprawne dane binarne i zaprezentować je w taki sposób, aby można je było poprawnie zapisać, jednak zwykle odbywa się to po stronie serwera, aby można było przeprowadzić prawidłowe typy mime i konwersję danych. – zzzzBov
zobacz http://stackoverflow.com/questions/15899883/generate-a-word-document-in-javascript-with-docx-js – Dan