Wednesday, 15 July 2015

javascript - How to give option to save a file instead of printing it from internet explorer -


I have written some javascript code to print some information using Internet Explorer using code below.

  if (IRPrint == 1) {window.print (); }  

isPrint is a variable to mark the document for printing only. I got the job to save it in local copy and it can be saved while printing in .xps format. I want to create a separate function which can save it directly in the form without showing it on the print menu. Can it be done

There is a great tutorial available on this, but the summary of it is that you I want to include the function that gets the internal HTML instead of just saving the JavaScript below. & Lt; HEAD & gt; & Lt; SCRIPT type = text / javascript & gt; Function save () {var fso = new ActiveXObject ("Scripting.FileSystemObject"); Var url = document.URL; Url = url.substring (url.lastIndexOf ('\\') + 1, url.length); Var s = fso.CreateTextFile (URL, true); S.WriteLine ('& lt; html id = myhtml & gt;'); S.WriteLine (document.getElementById ('myhtml') innerHTML.); S.WriteLine ('& lt; / html & gt;'); S.Close (); Document.location.href = url; } & Lt; / SCRIPT & gt; & Lt; / HEAD> & Lt; Body & gt; & Lt; SCRIPT type = text / javascript & gt; Document.write ("This is my first JavaScript!";);); & Lt; / Script & gt; & Lt; INPUT onclick = save (); Type = button value = Save & gt; & Lt; / Body & gt; & Lt; / Html & gt;


No comments:

Post a Comment