테스트 사이트 - 개발 중인 베타 버전입니다

부분 프린터하기

기존에 대부분 스킨에서 프린트 기능을 구현하려면,
간단하게는 window.print(); 를 사용해서 전체를 프린트 하게 하거나...
새창으로 띄워서 새창 전체를 프린트하는 기법을 사용하는데...

새창안을 띄우지 않고 필요한 부분만 프린트하는 소스입니다.
일단 게시물 본문만 프린트 하려면 아래와 같이 추가해 주시면 됩니다.


<iframe name=print_content id=print_content width=1 height=1 style="visibility:hidden;"></iframe>
<script>
function content_printer ()
{
print_content.document.open();
print_content.document.writeln("<html><head><style>body,td,p,pre,input,textarea,select,option,a,a:hover {font-size:9pt; font-family:tahoma,굴림;}</style></head><body>"); //스타일등을 지정
print_content.document.writeln('<?=$memo?>'); // 본문 출력
print_content.document.writeln("</body></html>");
print_content.document.close();

print_content.document.execCommand('Print');
}
</script>
<a onclick="content_printer();" style="cursor:hand;">프린트하기</a>

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

댓글 10개

잘 쓰겠습니다.
네..좋은 자료가 되었으면 좋겠네욧.
냠냠;;;;;;;;;
<script>
function printHTML() {
Pwin = window.open("","","width=900,height=800,scrollbars=1");
wdata ="<HTML>";
wdata += document.getElementById("print").innerHTML;
wdata += "";
Pwin.document.write(wdata);
Pwin.window.print();
Pwin.window.location.reload();
}

</script>



<div id="print">
프린트할부분을 div로 감싸준다
</div>

저는 이거 쓰는데..........
새로운 팁을 알게되었네요..감사합니다.

게시글 목록

번호 제목
27182
27176
18634
5442
18632
18629
5435
18627
18626
18623
5409
18621
18617
18615
18614
18608
27162
18607
5405
18606
18605
5401
27152
5397
18603
27144
20667
20666
24485
20651
20632
20620
20607
18602
30749
5396
18601
18599
18596
20590
18589
18587
18586
18585
18584
5387
27106
18583
18580
18579
27120
18574
18570
18566
18562
18558
26490
30733
18554
20572
20541
5377
18553
5373
20534
20531
20527
20525
20519
20513
20507
20503
20496
20490
20483
20471
20464
20447
20419
20405
30729
18549
18544
32084
32083
32082
32081
30728
27097
18537
27092
32080
32079
32078
32077
32076
32075
32074
32073
32072