Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created January 22, 2018 16:51
Show Gist options
  • Save parzibyte/004e326e7cf292f840ee2e0a233fe5ac to your computer and use it in GitHub Desktop.
Save parzibyte/004e326e7cf292f840ee2e0a233fe5ac to your computer and use it in GitHub Desktop.
function imprimirElemento(elemento) {
var ventana = window.open('', 'PRINT', 'height=400,width=600');
ventana.document.write('<html><head><title>' + document.title + '</title>');
ventana.document.write('<link rel="stylesheet" href="imprimir.css">'); //Cargamos otra hoja, no la normal
ventana.document.write('</head><body >');
ventana.document.write(elemento.innerHTML);
ventana.document.write('</body></html>');
ventana.document.close();
ventana.focus();
ventana.onload = function() {
ventana.print();
ventana.close();
};
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment