Reputation: 23
Upon clicking the Print button I get a Print Dialog.
Actual outcome:
When I click Cancel
on Print Dialog, it shows the print preview in the webpage.
Expected outcome: What I want is to show my actual webpage I was on prior to the Print Dialog bog.
Code for Printing:
function printMap(){
var printMapOnly = document.getElementById('regions_div').innerHTML;
document.body.innerHTML = printMapOnly;
window.print();
}
Print button:
<button class="btn btn-print" onclick="printMap('regions_div')">Print</button>
Upvotes: -1
Views: 149
Reputation: 23
Based on this I set my webpage's content back to its original content
Updated:
function printMap(){
var originalContent = document.body.innerHTML
var printMapOnly = document.getElementById('regions_div').innerHTML;
document.body.innerHTML = printMapOnly;
window.print();
document.body.innerHTML = originalContent;
}
Hope it helps someone else.
Upvotes: 1