diff --git a/jquery.wordexport.js b/jquery.wordexport.js index 6efb1d9..d7a60e3 100755 --- a/jquery.wordexport.js +++ b/jquery.wordexport.js @@ -1,7 +1,8 @@ if (typeof jQuery !== "undefined" && typeof saveAs !== "undefined") { (function($) { - $.fn.wordExport = function(fileName) { + $.fn.wordExport = function(fileName, autoSaveAs) { fileName = typeof fileName !== 'undefined' ? fileName : "jQuery-Word-Export"; + autoSaveAs = typeof autoSaveAs !== 'undefined' ? autoSaveAs : true; var static = { mhtml: { top: "Mime-Version: 1.0\nContent-Base: " + location.href + "\nContent-Type: Multipart/related; boundary=\"NEXT.ITEM-BOUNDARY\";type=\"text/html\"\n\n--NEXT.ITEM-BOUNDARY\nContent-Type: text/html; charset=\"utf-8\"\nContent-Location: " + location.href + "\n\n\n\n_html_", @@ -71,7 +72,10 @@ if (typeof jQuery !== "undefined" && typeof saveAs !== "undefined") { var blob = new Blob([fileContent], { type: "application/msword;charset=utf-8" }); - saveAs(blob, fileName + ".doc"); + if (autoSaveAs) { + saveAs(blob, fileName + ".doc"); + } + return blob; }; })(jQuery); } else {