[英]Printing a particular portion of a page
I am using this code to print a specific div inside a page 我正在使用此代码在页面内打印特定的div
var printCalender = function ()
{
var headstr = "<html><head><title></title></head><body>";
var footstr = "</body>";
var newstr = "<div style='text-align:center'><h2>Academic Calender - " + $scope.selectedSessionSelection + "</h2></div><br /><br />" + document.all.item('printportion').innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr + newstr + footstr;
window.print();
document.body.innerHTML = oldstr;
return false;
}
The problem is that, if I cancel printing, then I cannot execute any javascript on the page. 问题是,如果我取消打印,则无法在页面上执行任何JavaScript。
Use a Print only CSS file: 使用仅打印CSS文件:
<link rel="stylesheet" type="text/css" href="print.css" media="print">
This will only be read in print mode. 仅在打印模式下可以读取。
Then you can manipulate styles for print only. 然后,您可以操作仅用于打印的样式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.