我在ExtJS应用程序中打开一个html弹出窗口,并动态生成CSS和内容。该弹出窗口旨在将现有面板重新配置为对打印友好,并且可以像html一样保存。打印功能正常,但在Chrome中禁用了“另存为...”选项,我无法弄清楚原因。页面的实际URL不存在,因为内容是动态生成的(它打开为about:blank)所以我想这可能是问题所在。这是我正在使用的代码:
var myWindow = window.open('', 'Transcript', 'x=10, width=' + w + ',height="80%",resizable=yes,scrollbars=yes' );
myWindow.document.write('<!DOCTYPE HTML><html><head>');
myWindow.document.write('<title>' + 'Transcript' + '</title>');
myWindow.document.write('<link rel="stylesheet" href="resources/custom.css">');
myWindow.document.write('<link rel="stylesheet" href="resources/print.css">');
myWindow.document.write('<script>function printPage() { console.log(window.print()); }</script>');
myWindow.document.write('<style>' + cssStylesheetContents + '</style>');
myWindow.document.write('</head><body >');
myWindow.document.write(title);
myWindow.document.write('<div class="transcriptView">' + content + "</div>");
myWindow.document.write('</body></html>');
myWindow.document.close();
myWindow.focus();
myWindow.print();