This works fine for me
<script type="text/javascript">
function printPartOfPage(elementId) {
var printContent = document.getElementById(elementId);
//this is the id of the div in which the complete content is placed
var windowUrl = 'Test';
var uniqueName = new Date();
var windowName = 'Print' + uniqueName.getTime();
var printWindow = window.open(windowUrl, windowName, 'left=50,top=50,width=600,height=400');
printWindow.document.write(printContent.innerHTML);
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();
}</script>