﻿/*

업무용으로 사용할 게시판 스킨을 수정하면서 인쇄 기능이 필요해 검색하다 발견한
스크립트 소스 입니다. 업무일지 등의 특정 부분만 바로 출력할 수 있도록 구현이 되어 있습니다.
사용법은 일단 아래 스크립트를 페이지의 상단 부분에 넣습니다.

<script language="JavaScript">

    var initBody;

    function beforePrint(){ 
        initBody = document.body.innerHTML; 
        document.body.innerHTML = idPrint.innerHTML;
    } 

    function afterPrint(){ 
        document.body.innerHTML = initBody;
    } 

    function printArea() { 
        window.print(); 
    } 

    window.onbeforeprint = beforePrint; 
    window.onafterprint = afterPrint;

</script>

그럼 다음에 출력을 원하는 부분을 <div id="idPrintArea"> 와 </div>를 이용해 감싸 줍니다.
예를 들어 테이블의 출력하고자 한다면 <div id="idPrint"><table.....> ...... </table></div>
이런 식으로 감싸주면 div로 둘러싸여진 부분만 출력이 되게 됩니다.

인쇄하기 버튼은 <input type="button" value="인쇄하기" onclick="printArea();"> 와 같이
하시면 됩니다. 실제로 게시판 내용 출력 부분에 적용을 했는데 잘 출력이 되었습니다.

스크립트 출처 : http://www.blueb.co.kr/

출처 : Tong - 민뎅님의 javascript통

*/



    var initBody;

    function beforePrint() { 

        initBody                = document.body.innerHTML; 
        document.body.innerHTML = idPrintArea.innerHTML;

    } 





    function afterPrint() { 

        document.body.innerHTML = initBody;

    } 





    function printArea() { 

        window.print(); 

    } 


    window.onbeforeprint        = beforePrint; 
    window.onafterprint         = afterPrint;


