자유게시판

html에서 div로 지정한 특정 영역만 인쇄하기 / Print only specific areas designated as div in html

작성자 정보

  • 삼둡 작성
  • 작성일

컨텐츠 정보

본문

<a href="#" onclick="printArea()">인쇄하기NEW</a>
 

 

적당한 곳에 인쇄 링크를 넣는다.

Put the print link in the appropriate place as above.

814e72889888d19f3c0e55f29e03eeeadbb54a17k1ai.png

 

 

 

<!-- 엣지때문에 2022-12월에 추가함 -->
<script type="text/javascript">
<!--
var initBody;

function beforePrint() {
boxes = document.body.innerHTML;
document.body.innerHTML = box.innerHTML;
}
function afterPrint() {
document.body.innerHTML = boxes;
}
function printArea() {
window.print();
}

window.onbeforeprint = beforePrint;
window.onafterprint = afterPrint;

-->
</script>
 

이러한 스크립트를 head 안에 body 위 정도 적당한 곳에 넣는다.

Put these scripts in the head in the right place above the body.

0c11fa0eb53f87c1aeacaf5f8b6e6f969cf7e72eegot.png

 

 

<div ID="box">

 

<table border=1 cellspacing=0 width=350>
.....


</div>

 

인쇄를 원하는 영역에 div로 box를 지정한다.

Specify the box as a div in the area you want to print.

관련자료

댓글 0
등록된 댓글이 없습니다.

인기검색어


최근글


새댓글