[Javascript]원하는 HTML 영역 프린트하기
로빈아빠
본문
onPrint() {
const html = document.querySelector('html');
const printContents = document.querySelector('.modal-body').innerHTML;
const printDiv = document.createElement("DIV");
printDiv.className = "print-div";
html.appendChild(printDiv);
printDiv.innerHTML = printContents;
document.body.style.display = 'none';
window.print();
document.body.style.display = 'block';
printDiv.style.display = 'none';
}
출처 : https://milooy.wordpress.com/2017/03/28/javascript-print-page/
const html = document.querySelector('html');
const printContents = document.querySelector('.modal-body').innerHTML;
const printDiv = document.createElement("DIV");
printDiv.className = "print-div";
html.appendChild(printDiv);
printDiv.innerHTML = printContents;
document.body.style.display = 'none';
window.print();
document.body.style.display = 'block';
printDiv.style.display = 'none';
}
출처 : https://milooy.wordpress.com/2017/03/28/javascript-print-page/
관련링크
댓글목록
등록된 댓글이 없습니다.