Reputation: 803
I am using this code to print a specific div inside a page
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.
Upvotes: 1
Views: 32
Reputation: 103428
Use a Print only CSS file:
<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.
Upvotes: 2