I am trying to print an image from inside a div, the code runs ok but when the print dialog pops up, I would like the page to stay the same while actually it is showing only the picture as the window.reload
doesn't work for some reasons. The javascript is telling me in console "Uncaught TypeError: window.reload is not a function"
but i don't understand why.
function printDiv(printableArea) {
var printContents = document.getElementById("printableArea").innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
window.close();
window.reload();
}
Click to print
<input type="button" onclick="printDiv('printableArea')" value="print a div!" />
location.reload()
.