window.print禁用父窗口

时间:2019-04-16 11:50:58

标签: javascript

我需要打印从后端系统发送的html转储。在用户界面中单击按钮即可触发此打印。我正在使用window.print,如下所示。这里的问题是,在加载打印预览时,它不应阻止用户在父窗口中执行操作。但是,即使在新窗口上使用window.print时,父窗口也会被冻结并禁用。有没有一种方法可以使用户在父窗口中访问?

以下代码用于打印:

function printElem(elem){
                var newwindow = window.open('', 'PRINT');
        newwindow.document.write('<html><head><title>' + 
                document.title + '</title>');
        newwindow.document.write('</head><body >');
        newwindow.document.write(elem);
        newwindow.document.write('</body></html>');
                newwindow.focus();
                newwindow.print();
                newwindow.close();
 }

1 个答案:

答案 0 :(得分:0)

$('#Button').attr('disabled','disabled');

在打开打印窗口之前添加此代码(var newwindow = window.open('', 'PRINT');

相关问题