Home >Web Front-end >JS Tutorial >JS implements partial selection printing and partial non-selection printing_javascript skills

JS implements partial selection printing and partial non-selection printing_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:53:271555browse

Select the content to be printed on a page due to the needs of the project.

Wrap the thing you want to print in a DIV layer. For example:

Copy code The code is as follows:


(Notice number: ${zjxfItemUser. acceptedNo })

Notice of transfer of petition matters${zjxfItemUser.userName }: (name of petitioner)

       
, this agency (or unit) The ${zjxfItemUser.subject} petition filed by you (or you) has been accepted in accordance with the law.
The petition matter falls within the scope of XXX’s powers. According to the relevant provisions of the "Petition Regulations", this agency has already The relevant materials will be transferred to XXX for processing on XX, please contact him in time.

We hereby inform you.

(stamped with ${zjxfProcessOver.subOrgname} special seal or official seal)





No printing required in the middle , also included in a DIV layer. Utilize CSS styles. Simply reference class="noprint" in the layer that does not need to be printed





JS Code:

Note: The style will be lost when you choose to print. You need to add your print before printing.


$(function(){

$("#print").click(function(){

var html = window.document.body.innerHTML;

exportCSS("itemVrbjForm",html);

});

//Import styles into selected printing
function exportCSS(formName,htmlInfo){
var CSS = " "
" "
""
""
"" ;
$(CSS).appendTo("#" formName);
window.document.body.innerHTML = $("#" formName).html();
window.print();
window.document.body.innerHTML = htmlInfo;
}

});


In this way, both partial selection printing and partial non-selection printing can be achieved
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn