这是我得到的功能 - 感谢 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>
它打开的窗口效果很好;文件正在打印样式和所有内容,但窗口未关闭,
知道为什么吗?
非常感谢
最佳答案
尝试
termsAndConditions.close();
关于javascript - 打开 document.windows,打印它并关闭它(不关闭),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7118595/