lipon
lipon

Reputation: 11

Prevent print preview dialog and directly print element

How can I print a div element with click on print button without opening print preview popup with JavaScript.

function printContent(el) {
 var restorepage = document.body.innerHTML;
 var printcontent = document.getElementById(el).innerHTML;
 document.body.innerHTML = printcontent;
 window.print();
 document.body.innerHTML = restorepage;
}

Upvotes: 0

Views: 170

Answers (1)

Akxe
Akxe

Reputation: 11495

Short answer:

No.

However, you could develop browser extension that might be capable of doing so. Thought, it would be way too much effort for little result.

Upvotes: 1

Related Questions