Open document.windows, print it and close it (doesn't close)
This are the functions I got to -thanks to the search option in stackoverflow and some modifications of mine-
<script type="text/javascript">
function imprimirElemento(elem)
{
abrirElemento($(elem).html());
}
function abrirElemento(data)
{
var style = '<style type="text/css">.titulosLightBox {border-bottom: 1px dotted #D1D1D1;color: #333333;font-size: 20px;font-weight: normal;line-height: 18px;margin-bottom: 15px;padding-bottom: 10px;}'+'strong{width:100%;font-weight:bold;}'+'</style>';
var termsAndConditions = window.open('', 'tos', 'height=400,width=600');
termsAndConditions.document.write('<html><head><title>Politica de Privacidad</title>');
termsAndConditions.document.write(style);
termsAndConditions.document.write('</head><body >');
termsAndConditions.document.write(data);
termsAndConditions.document.write('</body></html>');
开发者_Python百科 termsAndConditions.document.close();
termsAndConditions.print();
termsAndConditions.document.close(); /*This seems not to work*/
return true;
}
</script>
It works great, the window it's opened; the file is getting printed with styles and everything but the window its not closed,
any idea why?
thanks a lot
Try
termsAndConditions.close();
The last line is wrong, because you have already closed the document object. Try termsAndConditions.close()
精彩评论