Print div content only in javascript

From Code Trash
Jump to: navigation, search
function printit()
{
	var prtContent = document.getElementById("dire");
	var WinPrint = document.getElementById("ifmPrintContents").contentWindow;
	WinPrint.document.open();
	WinPrint.document.write(prtContent.innerHTML);
	WinPrint.document.close();
	WinPrint.focus();
	WinPrint.print();
}
<iframe id="ifmPrintContents" style="height: 0px; width: 0px; position: absolute"></iframe>

Reference