보통 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에서 이동 됨]
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 2330 | 16년 전 | 5070 | ||
| 2329 | 16년 전 | 2305 | ||
| 2328 | 16년 전 | 3404 | ||
| 2327 | 16년 전 | 2640 | ||
| 2326 | 16년 전 | 1558 | ||
| 2325 | 16년 전 | 5358 | ||
| 2324 | 16년 전 | 2471 | ||
| 2323 | 16년 전 | 5964 | ||
| 2322 | 16년 전 | 1939 | ||
| 2321 | 16년 전 | 4019 | ||
| 2320 | 16년 전 | 3032 | ||
| 2319 |
|
16년 전 | 2216 | |
| 2318 |
데니크레인
|
16년 전 | 2236 | |
| 2317 | 16년 전 | 4417 | ||
| 2316 | 16년 전 | 3305 | ||
| 2315 | 16년 전 | 2835 | ||
| 2314 | 16년 전 | 2962 | ||
| 2313 | 16년 전 | 2078 | ||
| 2312 | 16년 전 | 1768 | ||
| 2311 | 16년 전 | 1678 | ||
| 2310 | 16년 전 | 1398 | ||
| 2309 | 16년 전 | 1670 | ||
| 2308 | 16년 전 | 1902 | ||
| 2307 | 16년 전 | 1599 | ||
| 2306 |
|
16년 전 | 4849 | |
| 2305 | 16년 전 | 3828 | ||
| 2304 | 16년 전 | 1789 | ||
| 2303 | 16년 전 | 1534 | ||
| 2302 | 16년 전 | 2271 | ||
| 2301 | 16년 전 | 4536 | ||
| 2300 | 16년 전 | 3560 | ||
| 2299 | 16년 전 | 2588 | ||
| 2298 | 16년 전 | 4358 | ||
| 2297 | 16년 전 | 3227 | ||
| 2296 | 16년 전 | 1367 | ||
| 2295 |
|
16년 전 | 1383 | |
| 2294 |
|
16년 전 | 2041 | |
| 2293 | 16년 전 | 1888 | ||
| 2292 | 16년 전 | 2564 | ||
| 2291 | 16년 전 | 2234 | ||
| 2290 | 16년 전 | 1372 | ||
| 2289 | 16년 전 | 4392 | ||
| 2288 | 16년 전 | 1478 | ||
| 2287 | 16년 전 | 1791 | ||
| 2286 | 16년 전 | 2201 | ||
| 2285 |
|
16년 전 | 3846 | |
| 2284 |
|
16년 전 | 2736 | |
| 2283 |
|
16년 전 | 1494 | |
| 2282 | 16년 전 | 4025 | ||
| 2281 |
|
16년 전 | 1402 | |
| 2280 | 16년 전 | 1588 | ||
| 2279 | 16년 전 | 1246 | ||
| 2278 | 16년 전 | 1714 | ||
| 2277 | 16년 전 | 1616 | ||
| 2276 | 16년 전 | 1627 | ||
| 2275 | 16년 전 | 1426 | ||
| 2274 | 16년 전 | 2187 | ||
| 2273 | 16년 전 | 1835 | ||
| 2272 |
|
16년 전 | 1982 | |
| 2271 | 16년 전 | 2197 | ||
| 2270 |
a1system
|
16년 전 | 1487 | |
| 2269 | 16년 전 | 2317 | ||
| 2268 | 16년 전 | 2260 | ||
| 2267 | 16년 전 | 4537 | ||
| 2266 |
|
16년 전 | 1295 | |
| 2265 | 16년 전 | 1054 | ||
| 2264 |
잠자리똥꾸멍
|
16년 전 | 2012 | |
| 2263 |
태양의서쪽
|
16년 전 | 1978 | |
| 2262 |
태양의서쪽
|
16년 전 | 1520 | |
| 2261 |
태양의서쪽
|
16년 전 | 2046 | |
| 2260 |
|
16년 전 | 2276 | |
| 2259 | 16년 전 | 1387 | ||
| 2258 | 16년 전 | 1738 | ||
| 2257 | 16년 전 | 1921 | ||
| 2256 | 16년 전 | 1014 | ||
| 2255 | 16년 전 | 1689 | ||
| 2254 | 16년 전 | 1406 | ||
| 2253 | 16년 전 | 1917 | ||
| 2252 |
freedays
|
16년 전 | 1326 | |
| 2251 | 16년 전 | 2201 | ||
| 2250 | 16년 전 | 1880 | ||
| 2249 | 16년 전 | 5871 | ||
| 2248 | 16년 전 | 1913 | ||
| 2247 | 16년 전 | 3686 | ||
| 2246 | 16년 전 | 1467 | ||
| 2245 |
|
16년 전 | 1758 | |
| 2244 |
|
16년 전 | 2075 | |
| 2243 | 16년 전 | 2610 | ||
| 2242 | 16년 전 | 2310 | ||
| 2241 | 16년 전 | 2759 | ||
| 2240 | 16년 전 | 2997 | ||
| 2239 | 16년 전 | 3027 | ||
| 2238 |
|
16년 전 | 1825 | |
| 2237 |
|
16년 전 | 1541 | |
| 2236 |
|
16년 전 | 1418 | |
| 2235 | 16년 전 | 1727 | ||
| 2234 | 16년 전 | 1209 | ||
| 2233 | 16년 전 | 1960 | ||
| 2232 |
|
16년 전 | 1732 | |
| 2231 | 16년 전 | 1606 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기