I try to print a "div" in which there is a "proof of an order, I can not keep the CSS styles when I open the print window.
This is my function:
function printDiv(divVer) {
var printContents = document.getElementById(divVer).innerHTML;
var document_html = window.open("_blank");
document_html.document.write( "<html><head><title>Imprimir Pedido</title>" );
document_html.document.write( "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/styles.css\" media=\"all\">" );
document_html.document.write( "</head><body>" );
document_html.document.write( printContents );
document_html.document.write( "</body></html>" );
setTimeout(function () {
document_html.print();
}, 500)
}
$(document).on('click','#imprimirPedido' ,function() {
printDiv('divVer')
});
And this the DIV to print:
<div id="divVer" class="columna"> <h4 class="titulo">Detalles del Pedido</h4> </div>
It is empty, since it is filled from ajax, but the case that loses the css:
- How could I fix this? Thanks and regards.