Last active
April 26, 2016 18:16
-
-
Save cristofer-dev/2de22ab7365cdda9b95f1ab0c6d5b8e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" charset="utf-8"> | |
function imprimir(){ | |
var objeto=document.getElementById('div_imprimir'); //obtenemos el objeto a imprimir | |
var ventana=window.open('','_blank'); //abrimos una ventana vacía nueva | |
ventana.document.write(objeto.innerHTML); //imprimimos el HTML del objeto en la nueva ventana | |
ventana.document.write('<link rel="stylesheet" href="/static/css/mi_hoja1.css">'); // incluyes los css | |
ventana.document.write('<link rel="stylesheet" href="/static/css/mi_hoja2.css">'); // incluyes los css | |
ventana.document.close(); //cerramos el documento | |
// Chrome no tomaba el contenido, hubo que ponerle seTime para que funcionara | |
setTimeout(function(){ | |
ventana.print(); //imprimimos la ventana | |
ventana.close(); //cerramos la ventana | |
},2); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment