웹프로그래밍/Javascript
지정된 영역만 인쇄하기
jihun202
2015. 6. 15. 10:06
반응형
<html>
<head>
<style>
div { position: relative; }
</style>
<script>
var initBody;
function beforePrint()
{
initBody=document.body.innerHTML;
document.body.innerHTML=idPrint.innerHTML;
}
function afterPrint()
{
document.body.innerHTML=initBody;
}
window.onbeforeprint = beforePrint;
window.onafterprint = afterPrint;
</script>
</head>
<body>
<div id="idPrint">
<b>[첫 번째 영역]</b><br>첫 번째 영역입니다!<br><br>
</div>
<b>[두 번째 영역]</b><br>두 번째 영역입니다!<br><br>
<b>[세 번째 영역]</b><br>세 번째 영역입니다!<br>
<input type="button" onclick="window.print()" value="첫번째 영역만 인쇄">
[출처] http://blog.naver.com/masca727/60038165332
</body>
</html>
<head>
<style>
div { position: relative; }
</style>
<script>
var initBody;
function beforePrint()
{
initBody=document.body.innerHTML;
document.body.innerHTML=idPrint.innerHTML;
}
function afterPrint()
{
document.body.innerHTML=initBody;
}
window.onbeforeprint = beforePrint;
window.onafterprint = afterPrint;
</script>
</head>
<body>
<div id="idPrint">
<b>[첫 번째 영역]</b><br>첫 번째 영역입니다!<br><br>
</div>
<b>[두 번째 영역]</b><br>두 번째 영역입니다!<br><br>
<b>[세 번째 영역]</b><br>세 번째 영역입니다!<br>
<input type="button" onclick="window.print()" value="첫번째 영역만 인쇄">
[출처] http://blog.naver.com/masca727/60038165332
</body>
</html>
반응형