2010-08-30 61 views

回答

2

笨是一個很好的框架,但遺憾的是並不十分適用於這種情況,因爲PHP是一種服務器端腳本語言和打印完成客戶方。對於打印給定區域,您將需要使用一些javascript,指定要打印的div。我會推薦jQuery庫,因爲它在我的一些項目中使用了一個打印插件。所以你會使用php來定義這樣的代碼

<div id="content"> ... </div> 

<div id="print_button">Print</div> 

<script type="text/javascript"> 
    // javascript goes here, if you were using jQuery 
    // with the PrintArea pluginyou might do... 
    $("div#print_button").click(function(){ 
    $("div#content").printArea([options]); 
    }); 
</script> 

然後當按下打印按鈕時執行客戶端。

退房的jQuery這裏http://jquery.com/

還有與設置打印樣式表,如果你不想使用jQuery的香草window.print()函數。

+0

非常感謝您的寶貴答案,也一定會結帳jquery ......再次感謝! – 2010-08-30 16:56:39

1

如果要定義某些元素要打印只需要創建一個單獨的CSS樣式表:

<link rel="stylesheet" href="print.css" type="text/css" media="print" /> 

不應印刷可以使用display: none;隱藏每個元素。有關更多信息,請參見this page

+0

感謝您的幫助Nick,我現在是指您的鏈接!再次感謝您! – 2010-08-30 16:57:42

相關問題