보통 print 함수 사용시 원하지 않는 부분이 출력되는데 div 를 이용하여 원하는 부분만 출력이 가능합니다.
<HTML>
<HEAD>
<STYLE>
DIV { position: relative; }
</STYLE>
<SCRIPT>
var div2print;
function printDiv (id) {
if (document.all && window.print) {
div2print = document.all[id];
window.onbeforeprint = hideDivs;
window.onafterprint = showDivs;
window.print();
}
else if (document.layers) {
div2print = document[id];
hideDivs();
window.print();
}
}
function hideDivs () {
if (document.all) {
var divs = document.all.tags('DIV');
for (var d = 0; d < divs.length; d++)
if (divs[d] != div2print)
divs[d].style.display = 'none';
}
else if (document.layers) {
for (var l = 0; l < document.layers.length; l++)
if (document.layers[l] != div2print)
document.layers[l].visibility = 'hide';
<HEAD>
<STYLE>
DIV { position: relative; }
</STYLE>
<SCRIPT>
var div2print;
function printDiv (id) {
if (document.all && window.print) {
div2print = document.all[id];
window.onbeforeprint = hideDivs;
window.onafterprint = showDivs;
window.print();
}
else if (document.layers) {
div2print = document[id];
hideDivs();
window.print();
}
}
function hideDivs () {
if (document.all) {
var divs = document.all.tags('DIV');
for (var d = 0; d < divs.length; d++)
if (divs[d] != div2print)
divs[d].style.display = 'none';
}
else if (document.layers) {
for (var l = 0; l < document.layers.length; l++)
if (document.layers[l] != div2print)
document.layers[l].visibility = 'hide';
}
}
function showDivs () {
var divs = document.all.tags('DIV');
for (var d = 0; d < divs.length; d++)
divs[d].style.display = 'block';
}
</SCRIPT>
</HEAD>
<BODY>
<DIV>
<p><font size="2"><b>아래 선택 상자에서 원하는 인쇄 영역을 선택한 다음 "특정 부분 인쇄" 버튼을 클릭하세요!</b></font></p>
<FORM>
<SELECT NAME="divSelect">
<OPTION value="d1">첫 번째 영역만 인쇄
<OPTION value="d2">두 번째 영역만 인쇄
<OPTION value="d3">세 번째 영역만 인쇄
</SELECT>
<INPUT TYPE="button"
ONCLICK="var s = this.form.divSelect;
var divID = s.options[s.selectedIndex].value;
printDiv(divID);"
VALUE="특정 부분 인쇄"
>
</FORM>
</DIV>
<DIV ID="d1">
<b>[첫 번째 영역]</b><br>
첫 번째 영역입니다!<br><br>
</DIV>
<DIV ID="d2">
<b>[두 번째 영역]</b><br>
두 번째 영역입니다!<br>
두 번째 영역을 선택하여 인쇄해 보세요!<br><br>
</DIV>
<DIV ID="d3">
<b>[세 번째 영역]</b><br>
세 번째 영역입니다!<br>
세 번째 영역을 선택하여 인쇄해 보세요!<br>
}
function showDivs () {
var divs = document.all.tags('DIV');
for (var d = 0; d < divs.length; d++)
divs[d].style.display = 'block';
}
</SCRIPT>
</HEAD>
<BODY>
<DIV>
<p><font size="2"><b>아래 선택 상자에서 원하는 인쇄 영역을 선택한 다음 "특정 부분 인쇄" 버튼을 클릭하세요!</b></font></p>
<FORM>
<SELECT NAME="divSelect">
<OPTION value="d1">첫 번째 영역만 인쇄
<OPTION value="d2">두 번째 영역만 인쇄
<OPTION value="d3">세 번째 영역만 인쇄
</SELECT>
<INPUT TYPE="button"
ONCLICK="var s = this.form.divSelect;
var divID = s.options[s.selectedIndex].value;
printDiv(divID);"
VALUE="특정 부분 인쇄"
>
</FORM>
</DIV>
<DIV ID="d1">
<b>[첫 번째 영역]</b><br>
첫 번째 영역입니다!<br><br>
</DIV>
<DIV ID="d2">
<b>[두 번째 영역]</b><br>
두 번째 영역입니다!<br>
두 번째 영역을 선택하여 인쇄해 보세요!<br><br>
</DIV>
<DIV ID="d3">
<b>[세 번째 영역]</b><br>
세 번째 영역입니다!<br>
세 번째 영역을 선택하여 인쇄해 보세요!<br>
</DIV></BODY>
</HTML>
</HTML>
네이버 지식인 에서 발취 저작권 문제시 삭제 하겠습니다.
[이 게시물은 관리자님에 의해 2011-10-31 17:16:08 PHP & HTML에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 8130 | 9년 전 | 575 | ||
| 8129 |
|
9년 전 | 688 | |
| 8128 | 9년 전 | 543 | ||
| 8127 |
|
9년 전 | 591 | |
| 8126 | 9년 전 | 524 | ||
| 8125 | 9년 전 | 778 | ||
| 8124 |
|
9년 전 | 537 | |
| 8123 | 9년 전 | 523 | ||
| 8122 | 9년 전 | 456 | ||
| 8121 | 9년 전 | 562 | ||
| 8120 | 9년 전 | 482 | ||
| 8119 | 9년 전 | 571 | ||
| 8118 |
|
9년 전 | 648 | |
| 8117 |
|
9년 전 | 415 | |
| 8116 |
PASKRAN
|
9년 전 | 474 | |
| 8115 | 9년 전 | 470 | ||
| 8114 |
kiplayer
|
9년 전 | 607 | |
| 8113 | 9년 전 | 467 | ||
| 8112 |
|
9년 전 | 575 | |
| 8111 | 9년 전 | 414 | ||
| 8110 | 9년 전 | 457 | ||
| 8109 | 9년 전 | 388 | ||
| 8108 |
|
9년 전 | 565 | |
| 8107 |
|
9년 전 | 453 | |
| 8106 |
|
9년 전 | 455 | |
| 8105 | 9년 전 | 485 | ||
| 8104 |
|
9년 전 | 450 | |
| 8103 |
|
9년 전 | 450 | |
| 8102 |
|
9년 전 | 424 | |
| 8101 |
snshero
|
9년 전 | 808 | |
| 8100 | 9년 전 | 855 | ||
| 8099 | 9년 전 | 831 | ||
| 8098 | 9년 전 | 732 | ||
| 8097 | 9년 전 | 540 | ||
| 8096 | 9년 전 | 736 | ||
| 8095 | 9년 전 | 871 | ||
| 8094 | 9년 전 | 544 | ||
| 8093 | 9년 전 | 822 | ||
| 8092 | 9년 전 | 774 | ||
| 8091 | 9년 전 | 1158 | ||
| 8090 | 9년 전 | 784 | ||
| 8089 | 9년 전 | 998 | ||
| 8088 | 9년 전 | 660 | ||
| 8087 | 9년 전 | 787 | ||
| 8086 | 9년 전 | 535 | ||
| 8085 | 9년 전 | 501 | ||
| 8084 | 9년 전 | 619 | ||
| 8083 | 9년 전 | 592 | ||
| 8082 | 9년 전 | 781 | ||
| 8081 | 9년 전 | 490 | ||
| 8080 | 9년 전 | 586 | ||
| 8079 | 9년 전 | 546 | ||
| 8078 | 9년 전 | 465 | ||
| 8077 | 9년 전 | 554 | ||
| 8076 | 9년 전 | 425 | ||
| 8075 | 9년 전 | 457 | ||
| 8074 | 9년 전 | 420 | ||
| 8073 | 9년 전 | 478 | ||
| 8072 | 9년 전 | 468 | ||
| 8071 |
o1o111
|
9년 전 | 917 | |
| 8070 | 9년 전 | 426 | ||
| 8069 | 9년 전 | 362 | ||
| 8068 | 9년 전 | 616 | ||
| 8067 | 9년 전 | 415 | ||
| 8066 | 9년 전 | 442 | ||
| 8065 | 9년 전 | 400 | ||
| 8064 | 9년 전 | 394 | ||
| 8063 | 9년 전 | 363 | ||
| 8062 | 9년 전 | 333 | ||
| 8061 | 9년 전 | 368 | ||
| 8060 | 9년 전 | 407 | ||
| 8059 | 9년 전 | 344 | ||
| 8058 | 9년 전 | 281 | ||
| 8057 | 9년 전 | 410 | ||
| 8056 | 9년 전 | 330 | ||
| 8055 | 9년 전 | 374 | ||
| 8054 | 9년 전 | 383 | ||
| 8053 | 9년 전 | 434 | ||
| 8052 | 9년 전 | 306 | ||
| 8051 | 9년 전 | 356 | ||
| 8050 | 9년 전 | 413 | ||
| 8049 | 9년 전 | 346 | ||
| 8048 | 9년 전 | 449 | ||
| 8047 | 9년 전 | 388 | ||
| 8046 | 9년 전 | 331 | ||
| 8045 | 9년 전 | 279 | ||
| 8044 | 9년 전 | 364 | ||
| 8043 | 9년 전 | 322 | ||
| 8042 | 9년 전 | 313 | ||
| 8041 | 9년 전 | 372 | ||
| 8040 | 9년 전 | 296 | ||
| 8039 | 9년 전 | 338 | ||
| 8038 | 9년 전 | 281 | ||
| 8037 | 9년 전 | 427 | ||
| 8036 | 9년 전 | 515 | ||
| 8035 | 9년 전 | 447 | ||
| 8034 | 9년 전 | 407 | ||
| 8033 | 9년 전 | 368 | ||
| 8032 | 9년 전 | 471 | ||
| 8031 | 9년 전 | 364 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기