I am using a default print function for printing, but once print function is completed i am not able to click other tabs. Print window is opening in the same page
function printReport() {
var divElements = $('.nicEdit-main').html();
var oldPage = document.body.innerHTML;
document.body.innerHTML = "<html><head><title></title></head><body>" + divElements + "</body>";
window.print();
document.body.innerHTML = oldPage;
}
The print() method prints the contents of the current window.
Unfortunately, you just replaced the entire body of your page. innerHTML
only returns a string form of the HTML minus the handlers and any data attached to the elements. Setting the innerHTML
recreates the DOM from that string without the handlers that were originally attached. You just "effectively" paralyzed the page!
I suggest:
The hard way would be to continue what you are doing, but delegate all handlers to document
like how live
would have done it so that they won't be removed. Hard, possible, but not scalable, maintainable or optimal.
Or you could just create a hidden iframe
and place your content to be printed there. Then call print
from that iframe window
instead. That way, you won't lose your current page.
Others would create a new window, put content there, run print and close it immediately after. Works the same as iframes, but you wouldn't want a creepy window that opens and closes immediately like some pop-up ad.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With