Here I only posted my js part of the code .... The main focus of HTML code is to put the part that needs to be printed
"<!--startprint1--> <!--endprint1-->" can be
| The code is as follows |
Copy Code |
| var bdhtml=window.document.body.innerhtml; Get the entire page before you print it function Printme () { Get the HTML code for the current page var sprnstr= "<!--startprint1-->";//Set the place where the print starts var eprnstr= "<!--endprint1-->";//Set the place where the print ends var prnhtml=bdhtml.substring (Bdhtml.indexof (SPRNSTR) +18); To fetch HTML backwards from where you set the print start Prnhtml=prnhtml.substring (0,prnhtml.indexof (EPRNSTR));//forward HTML from the end of set printing At this point in the prnhtml is what you need to print. window.document.body.innerhtml=prnhtml to replace the page with what needs to be printed. Window.print (); print SetTimeout (goback,1000); Set delay one second page returns the same as before printing
}
function GoBack () { window.document.body.innerhtml=bdhtml;//the contents of the page back. } |