我正在尝试使用打印新打开的窗口。window.print()
我的问题是,只打印页面的起始部分(只有当您滚动到窗口左上角时看到的内容)。
这是我的代码:
var printWindow = window.open("", "Print", "width=" + nWidth + "px, height=" + nHeight+ "px");
printWindow.document.write(sSvgData, sDivData);
printWindow.document.close();
printWindow.print();
我已经尝试过的解决方案,但对我不起作用:
1)将整个html写入文档(使用),并将my包含在标题中window.document.write()css
<html><head><link rel="stylesheet" href="../css/style.css" type="text/css" media="print"/></head>
<body>...
style.css:
@media print {
body, html, div, #wrapper {
height: 100%;
width: 100%;
}
}
2) 与 1) 相同,但包括内联样式,如:
<html><style>@media print { body, html, #wrapper { height: 100%; width: 100%;} }</style><body>...
忽然笑
相关分类