2014-01-30 4 views
0

CallPrint 기능에 헤더를 추가하는 방법 :자바 스크립트 - 나는 자바 스크립트 함수가

<script type="text/javascript"> 
function CallPrint(strid) { 
    var prtContent = document.getElementById(strid); 
    var WinPrint = window.open('', '', 'left=0, top=0, width=970, height=500, toolbar=0, scrollbars=0, status=0'); 
    WinPrint.document.write(prtContent.innerHTML); 
    WinPrint.document.close(); 
    WinPrint.focus(); 
    WinPrint.print(); 
    WinPrint.close(); 
    } 
</script> 

을하고 버튼의 : 지금 작동하고 나는 페이지의 특정 부분을 인쇄 할 수 있지만,

onClick="javascript:CallPrint('printarea')" 

로고가있는 헤더와 페이지 인쇄시 표시되는 연락처 정보를 추가하고 싶습니다.

답변

0

@media print CSS 태그를 사용하십시오. 본질적으로 display:none@media print이있는 스타일을 만듭니다. 같은

뭔가 :

<style media="screen"> 
    .onlyPrint{ display: none; } 
</style> 

<style media="print"> 
    .onlyPrint{ display: block; } 
</style> 

당신은 정기적으로 당신의 자바 스크립트를 호출하고 연주 화면 또는 프린터에 있는지 여부에 따라 CSS 로고와 헤더의 표시/숨기기를 처리

+0

나는 그것을 작동하게 만들 수 없다. 새 스타일 추가 = "print"내 CSS 코드로 페이지에 있지만 작동하지 않습니다.

+0

이것은 좋은 출발점입니다. http://coding.smashingmagazine.com/2011/11/24/how-to-set-up-a-print-style-sheet/ – raidenace

+0

....
그건 내 사업부입니다. –

관련 문제