[英]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- 这是我得到的函数 - 谢谢stackoverflow中的搜索选项和我的一些修改 -
<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>');
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 非常感谢
尝试
termsAndConditions.close();
The last line is wrong, because you have already closed the document object. 最后一行是错误的,因为您已经关闭了文档对象。 Try
termsAndConditions.close()
试试
termsAndConditions.close()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.