Js partial page print really good Dongdong

 
JS achieve a simple partial print pages 
JScript code
 
            
function preview (Oper) ...... { IF (Oper < 10 ) {...... bdhtml = window.document.body.innerHTML; // Get html code of this page sprnstr = " <-! startprint " + Oper + " -> " ; // set the print start region eprnstr = " <- EndPrint! " + Oper + " -> " ; // set the print end region prnhtml = bdhtml.substring (bdhtml.indexOf (sprnstr) + 18 is ); // Taken back from the start code html prnhtml = prnhtml.substring ( 0 , prnhtml.indexOf (eprnstr)); // get html forwardly from the end code window.document.body.innerHTML = prnhtml; window.print (); window. document.body.innerHTML = bdhtml;} the else ...... window.print {();}}


Very simple to use content within the page to be printed join the middle <-! Startprint1 -> XXXXX < -! Endprint1 ->
plus print button οnclick = preview (1)
 
 

 

 

 
Content is an iframe, to take the framework that handle, to take a iframe id number such as aaa, window.frames [ "aaa"] This is the handle, and then print the entire contents is window.frames [ "aaa"]. print (); // if we want to print the contents of the local portion inside iframe, the code can be seen the second floor.
Published 10 original articles · won praise 0 · views 10000 +

Guess you like

Origin blog.csdn.net/lwbsleep/article/details/7285677