Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
180
rated 0 times [  183] [ 3]  / answers: 1 / hits: 19891  / 13 Years ago, mon, october 17, 2011, 12:00:00

My print html is below



<div id=DivIdToPrint style=border:1px solid #000000;>
fdghgjhghjkjk
<div id=in>TO be are not to be that is the question</div>
</div>


and javascript code is :



function printDiv()
{
var divToPrint=document.getElementById('DivIdToPrint');
var newWin=window.open('','Print-Window','width=400,height=400,top=100,left=100');
newWin.document.open();
newWin.document.write('<html><body onload=window.print()>'+divToPrint.innerHTML+'</body></html>');
newWin.document.close();
setTimeout(function(){newWin.close();},10);

}


I want to print DivIdToPrint div but don't show in div content.


More From » html

 Answers
13

In your JS code add style to hide the in div <style>#in {display:none}</style>, like this:



function printDiv()
{
var divToPrint=document.getElementById('DivIdToPrint');
var newWin=window.open('','Print-Window','width=400,height=400,top=100,left=100');
newWin.document.open();
newWin.document.write('<html><head><style>#in {display:none}</style><body onload=window.print()>'+divToPrint.innerHTML+'</body></html>');
newWin.document.close();
setTimeout(function(){newWin.close();},10);

}

[#89582] Friday, October 14, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shylaelisan

Total Points: 37
Total Questions: 94
Total Answers: 110

Location: Angola
Member since Tue, May 5, 2020
4 Years ago
;