My Code

Intenational Chemical Laboratory
Pune - 411008, India
(EPABX:+91(0)20-25902905, 25908901; Fax:+91(0)20-29902660)
REQUEST FOR HOUSE ACCOMMODATION
My Code

Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Vijay Pratap SinghRank #381 · 6.6K reputationPosted Jan 16, 2024, 6:05 AM EST
You can use JavaScript to create a function called printdiv() that will print the content of the "divPrint" section. Here's an example of how you can do it
Print Div Example Intenational Chemical Laboratory Pune - 411008, India (EPABX:+91(0)20-25902905, 25908901; Fax:+91(0)20-29902660) REQUEST FOR HOUSE ACCOMMODATION Print function printDiv() { var printContents = document.getElementById("divPrint").innerHTML; var originalContents = document.body.innerHTML; document.body.innerHTML = printContents; window.print(); document.body.innerHTML = originalContents; }Hope this will help
Mithun Pradhan194 reputationPosted Jan 16, 2024, 7:16 AM EST
My code
print window not open propper
need to like
open('', '', 'letf=0,top=0,width=800px,height=1000px,toolbar=0,scrollbars=0,Status=0');
Intenational Chemical Laboratory
Pune - 411008, India
(EPABX:+91(0)20-25902905, 25908901; Fax:+91(0)20-29902660)
REQUEST FOR HOUSE ACCOMMODATION
Incharge, Guest House
Naimish MakwanaRank #324 · 7.7K reputationPosted Jan 16, 2024, 6:04 AM EST
You can print a specific
divusing CSS and JavaScript. You can hide all other elements when printing by using a print media query. Here’s how you can do it:First, add this CSS to your stylesheet:
@media print { body * { visibility: hidden; } #divPrint, #divPrint * { visibility: visible; } #divPrint { position: absolute; left: 0; top: 0; } }This CSS will hide everything on the page, except for the
divPrintdiv and its inner elements, when printing.Then, modify your
printDivfunction like this:function printDiv() { window.print(); }Now, when you click the “Print” button, only the
divPrintsection will be printed. Please note that the actual printing will depend on the user’s browser settings and printer configuration.Thanks
Jignesh KumarRank #91 · 22.9K reputationPosted Jan 16, 2024, 7:36 AM EST
Hello Mithun,
Please create jquery method to print div as below,
function printDiv() { var divToPrint=document.getElementById('divPrint'); var newWin=window.open('','Print-Window'); newWin.document.open(); newWin.document.write(''+divToPrint.innerHTML+''); newWin.document.close(); setTimeout(function(){newWin.close();},10); }