프로그래밍Tips

특정부분만 영역설정해서 출력하기

itislord 2009. 6. 11. 17:17

<html파일>

<div id="print_content">

<table>

  <tr>

    <td>출력할 부분</td>

  </tr>

</table>

</div>

 

<a href="javascript:print_content('serviceaddress');"><img src="img/button2.gif" border="0" width="57" height="22" style="cursor:hand"/></a>                                   

 

[js파일]

/* 특정 부분을 출력할때 쓰임 */
function print_content(p_service){
 //alert("dfdf");
 window.open("/html/print_content.html","","directories=0,location=0,menubar=0,scrollbars=0,toolbar=0,width=500,height=500, left=5000, top=5000;");

// left와 top의 위치를 5000으로 해서 화면에는 안보이게 한다.
}

 

[print_content.html]

<html>
<head>
<link rel="stylesheet" type="text/css" href="/ktf/css/css.css">
</head>
<body onLoad="window.close();">
<form name="testform">
<input type="hidden" name="data" value>
</form>
<script language="javascript">
 {
  var print_all;
  (document.testform.data.value = window.opener.document.all.print_content.innerHTML);
  print_all = (document.testform.data.value);
  document.write (print_all);
  window.print();
 }
</script>
</body>
</html>

*********************************************************

출력버튼을 클릭하면 출력하는 화면이 뜨고 인쇄를 클릭하면

div태그에 쌓여진 부분만 출력하게 된다..

from.  http://blog.naver.com/flydrago?Redirect=Log&logNo=40005671910   김경용