天天看點

jQuery列印插件JQPRINT

jqprint是jquery的一個列印插件,是jprintarea的加強版(官網是這麼說的,具體可以看下面引自官網的一段話),可以列印標明的區域,沒有頁眉和頁腳,還是非常好用滴!要能運作這個列印插件當然要先引進相關js了,jquery當然是不可少的,還需要引進的就是jqprint的js。

jquery.jqprint-0.3.js下載下傳位址:http://download.csdn.net/detail/hongrj/4853985

<html>

<head>

<script language="javascript" src="jquery-1.7.1.min.js"></script>

<script language="javascript" src="jquery.jqprint-0.3.js"></script>

<script language="javascript">

function  a(){

$("#ddd").jqprint();

}

</script>

</head>

<body>

<div id="ddd">

<table>

<tr>

<td>test</td>

</tr>

</table>

</div>

<input type="button" onclick="a()" value="print"/>

</body>

</html>

可以以對象形式傳入四組參數

// 如果是true則可以顯示iframe檢視效果(iframe預設高和寬都很小,可以再源碼中調大),預設是false

debug: false,

// true表示引進原來的頁面的css,預設是true。(如果是true,先會找$("link[media=print]"),若沒有會去找$("link")中的css檔案)

importcss: true,

// 表示如果原來選擇的對象必須被納入列印(注意:設定為false可能會打破你的css規則)

printcontainer: true,

// 表示如果插件也必須支援歌opera浏覽器,在這種情況下,它提供了建立一個臨時的列印頁籤。預設是true

operasupport: true

調用方式

var o = $("#divtoprint");

o.jqprint();

$("#divtoprint").jqprint();

$('#divopera').jqprint({ operasupport: true });

以下是引自http://archive.plugins.jquery.com/project/jqprint jquery插件官網的一段注解

submitted by tanathos on may 13, 2009 - 5:16am

this plugin is designed upon the well known jprintarea, with some improvements and functionalities corrections. rewritten as true jquery plugin! version 0.3: now supports opera!

原帖位址:http://blog.csdn.net/hongrj/article/details/8265367

繼續閱讀