javascript - 打开 document.windows,打印它并关闭它(不关闭)

标签 javascript window

这是我得到的功能 - 感谢 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/

相关文章:

javascript - 如何检测onMouseOver的目标?

javascript - AngularJS 日期问题

javascript - 如果窗口调整大小时卸载 jquery 函数

delphi - 如何在Delphi中截取事件窗口的屏幕截图?

java - 如何从 java 8 中的 js 函数获取数组输出?

javascript - jshint 理解 Angular 吗?

javascript - Drop Ins Dropbox 插件错误

WPF 给出不正确的大小值

python - 如何只删除窗口边框?

Python "call()"函数不接受从 "abspath()"到文件的路径