Click here to Skip to main content
16,012,107 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear sir,

I have doubt for 'how to print part of html page using java script' ?

now i have whole page(HTML) print is successfully printing But,

How to print part of html????


By mohan
Posted
Updated 9-Dec-11 5:34am
v2

Try the following:
HTML print part of page by using JavaScript
HTML print part of page by using CSS

Let me know your result.
Enjoy :)
 
Share this answer
 
v3
Create a stylesheet for the print media and hide the sections you don't want to be printed

<link rel="stylesheet" type="text/css" media="print" href="print.css" />


print.css
<style>
.noprint
{
  display: none;
}
</style>
 
Share this answer
 
Put your code in particular div or panel and call using id of that control this will print part of your html page.

XML
<script language="javascript" type="text/javascript">
        function Clickheretoprint() {var disp_setting = "toolbar=yes,location=no,directories=yes,menubar=yes,";
            disp_setting += "scrollbars=yes,width=650, height=600, left=100, top=25";
            var content_vlue = document.getElementById('<%=dvPrintXL.ClientID %>').innerHTML;
            
            var docprint = window.open("", "", disp_setting);
            docprint.document.open();
            docprint.document.write('<html><head><title>Print Page</title>');
            docprint.document.write('</head><body><center>');
            docprint.document.write(content_vlue);
            docprint.document.write('</center></body></html>');
            docprint.print();
            docprint.document.close();
            docprint.focus(); 


Hope this will help you.
Don't forget to mark as answer if it helps. :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900