Skip to content

Instantly share code, notes, and snippets.

@thiyagaraj
Created February 27, 2012 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thiyagaraj/1926568 to your computer and use it in GitHub Desktop.
Save thiyagaraj/1926568 to your computer and use it in GitHub Desktop.
Print part of a webpage based on id
var printPage = function(id){
var html="<html><head><title>Print page</title>";
html+="</head><body>"
html+= document.getElementById(id).innerHTML;
html+="</body></html>";
var printWin = window.open('','','left=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status =0');
printWin.document.write(html);
printWin.document.close();
printWin.focus();
printWin.print();
printWin.close();
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment