27 May 2010 1 Comment

Print selected content from a webpage

This is an alternate to my post Javascript Print Page Area . Try this.

<script>
function cmdPrint()
{
var windowsettings = ” tollbar=yes,location=no,scrollbar=yes,width=600,height=500,left=100,top=50″;
var printcontent=document.getElementById(‘printerContent’);
var popupcontroler = windo.open(“”,”",windowsettings);
popupcontroler.document.open();
popupcontroler.document.write(‘<html><head><title>Printer Dilog</title>);
popupcontroler.document.write(‘</title><body onload=”self.print()”><div align=”center”>’);
popupcontroler.document.write(printcontent);
popupcontroler.document.write(‘</div></body></html>’);
popupcontroler.document.close();

</script>
Wrap your webpage content that need to be print with an id “printerContent”
<div id=”printerContent”>This is a test print. This is a test print. This is a test print. This is a test print.</div>
<a href=”#” onclick=”cmdPrint()”>Print</a>

VN:F [1.8.8_1072]
Rating: 0.0/10 (0 votes cast)
VN:F [1.8.8_1072]
Rating: 0 (from 0 votes)

One Response to “Print selected content from a webpage”

  1. Usually I do not post on blogs, but I would like to say that this article really forced me to do so! Thanks, really nice article.

    UN:F [1.8.8_1072]
    Rating: 0.0/5 (0 votes cast)
    UN:F [1.8.8_1072]
    Rating: 0 (from 0 votes)

Leave a Reply