Tag:printdomwindows
Article From:https://segmentfault.com/q/1010000012142037
Question:

At present, there is a management background. There are some instructions in the page, which need to print order information.window.print(),But the problem is only to print a part of it
1.Way 1:
First, get the page DOM, temporarily store it, then get the dom of the printing part, assign it to the page.window.document.body.innerHTML,When the printing is finished, then the stored DOM is assigned to it.window.document.body.innerHTML,The problem is that the instructions of the page are printed and failed.

      var tempHtml = window.document.body.innerHTML;
      var prnhtml = $('.dialog_warp .print-body').html();
      window.document.body.innerHTML = prnhtml; //Assign the specified content that needs to be printed to body.innerHTMLWindow.print (); / / invoke the print function of the browser to print the specified area.Window.document.body.innerHTML = tempHtml; / / / / re assigns the content of the page;

2.Mode two:
Create a new page to assign the contents of the print area to the new page.window.document.body.innerHTML,After printing, close the new page. The problem is that the page does not appear, or does not close the page after printing.
http://bbs.csdn.net/topics/39…

 var p='<html><head><title>Order printing < /title> < /head> < body> '+ $('.dialog_warp.Print-body').Html () +'< /body> +'</html> ';Var w = window.open ('about:blank');W.document.write (P);W.prinT ();W.close ();

Answer 0:

What do you do, plug in the plug-in
jqprint

Link of this Article: Print a page’s local DOM

Leave a Reply

Your email address will not be published. Required fields are marked *