Gooday Note Scrap Source Android login
 
작성일 : 11-11-28 10:05
[JavaScript] 원하는 부분만 인쇄하기
 글쓴이 : 기리 (123.♡.195.24)
조회 : 9,443  
   http://www.daerew.com/index.php?mid=WebTip&page=2&document_srl=16067 [672]

<head> 와 </head> 사이에 아래의 스크립트 소스를 삽입합니다.

<script type="text/javascript">
        var initBody
        function beforePrint()
        {
         initBody = document.body.innerHTML;
         document.body.innerHTML = DaeRewPrint.innerHTML;
        }

        function afterPrint()
        {
         document.body.innerHTML = initBody;
        }

        function printdaerew()
        {
         window.print();
        }

        window.onbeforeprint = beforePrint;
        window.onafterprint = afterPrint;
</script>


그 다음 인쇄할 부분을 아래와 같이 <div> 나 <table> 에 id 를 부여해서 삽입합니다.

예제) <div id="DaeRewPrint"> 대류커뮤니티에 오신 것을 환영합니다.</div>

마지막으로 출력버튼을 삽입합니다.

<input type="button" value="인쇄" onclick="printdaerew();">

이미지로 하신 분들은 아래와 같이합니다.

<image src="./images/etc/icon_page_print.gif" onclick="printArea();" style="cursor:pointer;">

기리 11-11-28 11:32
 123.♡.195.24  
<script language="javascript">
function ieExecWB( intOLEcmd, intOLEparam ) {
    // 웹 브라우저 컨트롤 생성.crabz
    var WebBrowser = "<object id='WebBrowser1' width=0 height=0 classid='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object>";

 

    // 웹 페이지에 객체 삽입
    document.body.insertAdjacentHTML("beforeEnd", WebBrowser);

 

    // if intOLEparam이 정의되어 있지 않으면 디폴트 값 설정
    if ( (!intOLEparam) || (intOLEparam < -1) || (intOLEparam > 1) )
        intOLEparam = 1;

 

    // ExexWB 메쏘드 실행
    WebBrowser1.ExecWB( intOLEcmd, intOLEparam );
    // 객체 해제
    WebBrowser1.outerHTML = "";
}
</script>

 

<input type="button" value="인쇄 미리 보기" onClick="window.ieExecWB(7)">
<input type="button" value="페이지 설정" onClick="window.ieExecWB(8)">
<input type="button" value="인쇄하기(대화상자 표시)" onClick="window.ieExecWB(6)">
<input type="button" value="인쇄 바로 하기" onClick="window.ieExecWB(6,-1)">

 
[출처] JAVASCRIPT로 인쇄 미리보기 만들기|작성자 가능성
http://www.nicklib.com/bbs/board.php?bo_table=bbs_script&wr_id=104
 
 

Total 121
번호 제   목 글쓴이 날짜 조회
121 [Java] 실행 오류 : 기본 클래스 []을 찾거나 로드할 … 기리 12-19 22829
120 [Java] 로봇클래스 - 마우스제어,키보드제어,화면캡… (1) 기리 06-20 22584
119 [Html] <br>태그 html에서 줄간격 사이즈 줄이기 … (1) 기리 11-01 18778
118 [Linux] 리눅스 마운트(mount) 명령어 기리 05-12 16777
117 [JavaScript] JavaScript (6) 기리 07-12 13490
116 [PHP] PHP 세션에서 시작, 변수등록, 변수삭제, 부수… 기리 04-22 11072
115 [Linux] 리눅스 - 복사 강제 덮어쓰기 (3) 관리자 02-23 9529
114 [JavaScript] 원하는 부분만 인쇄하기 (1) 기리 11-28 9444
113 [Linux] APM yum으로 설치하기 기리 08-22 8869
112 [Linux] CentOS Network 설정 (2) 기리 05-18 8825
111 svn 변경된 파일만 export 하기 (1) 관리자 02-28 8631
110 [MySql] 여러 테이블의 최근 게시물 추출 기리 07-11 8160
109 [PHP] PHP 5.3 버전 DEPRECATED 기리 05-14 8013
108 [Linux] 현재 접속자수 보기 netstat (1) 기리 10-12 7539
107 [MySql] 소켓에러 (3) 기리 04-25 7473
 1  2  3  4  5  6  7  8  9