打开文档.Windows,打印它并关闭它(不'不关闭)

Open document.windows, print it and close it (doesn't close)

本文关键字:文档 Windows 打印      更新时间:2023-09-26

这是我得到的函数-感谢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>

它工作得很好,它打开了窗口;文件正在打印样式和所有东西,但窗口没有关闭,

知道为什么吗?

thanks a lot

Try

termsAndConditions.close();

最后一行是错误的,因为您已经关闭了文档对象。尝试termsAndConditions.close()