【发布时间】:2018-11-04 03:37:33
【问题描述】:
我使用这种方法从我的 web 应用程序中复制一个 DIV 以在新选项卡中打印:https://stackoverflow.com/a/40389924/1062933 [谢谢!]
printForm(): void {
let printContents: any = document.getElementById('formTerms').innerHTML;
let w: any = window.open();
w.document.write(printContents);
w.document.write('<scr' + 'ipt type="text/javascript">' + 'window.onload = function() { window.print(); window.close(); };' + '</sc' + 'ript>');
w.document.close(); // necessary for IE >= 10
w.focus(); // necessary for IE >= 10
}
但生成的 HTML 未格式化,没有主选项卡中的 CSS。
有没有办法同时复制该 DIV 中使用的 CSS 样式?
我正在使用 Angular4 和 Teradata Covalent
【问题讨论】:
-
我需要这个,即使我必须复制原始页面的所有 CSS 才能使其正常工作......
-
Ctrl+S网页,完成。查找所有.css文件。 -
CSS文件由angular生成。
-
在每个构建中,它们都有不同的名称。那是卑鄙的人。
标签: javascript css angular