ITeye博客

JQPRINT-不错的jquery打印插件

chokee · 2014-07-30 16:42 · JS · html · Web前端 · Markdown

JQPRINT-不错的jquery打印插件 jqprint是jquery的一个打印插件,是jPrintArea的加强版(官网是这么说的,具体可以看下面引自官网的一段话),可以打印选定的区域,没有页眉和页脚大笑,还是非常好用滴!

   要能运行这个打印插件当然要先引进相关js了,jquery当然是不可少的,还需要引进的就是jqprint的js。

jquery.jqprint-0.3.js下载地址: http://download.csdn.net/detail/hongrj/4853985

示例: view plaincopy

可以以对象形式传入四组参数: view plaincopy {
debug: false,//如果是true则可以显示iframe查看效果(iframe默认高和宽都很小,可以再源码中调大),默认是false
importCSS: true, //true表示引进原来的页面的css,默认是true。(如果是true,先会找$("link"),若没有会去找$("link")中的css文件)
printContainer: true,//表示如果原来选择的对象必须被纳入打印(注意:设置为false可能会打破你的CSS规则)。
operaSupport: true//表示如果插件也必须支持歌opera浏览器,在这种情况下,它提供了建立一个临时的打印选项卡。默认是true
}

调用方式: view plaincopy var o = $("#divToPrint");
o.jqprint();
// or
$("#divToPrint").jqprint();
$('#divOpera').jqprint({ operaSupport: true });

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

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!

HOW IT WORKS Just calling the jqprint() method on jQuery object or selector:

var o = $("#divToPrint"); o.jqprint(); // or $("#divToPrint").jqprint(); $('#divOpera').jqprint({ operaSupport: true });

PARAMETERS

debug - Allows you to choose to make visible the iframe used for printing. importCSS - Css links in original page will be imported into iframe. First it searchs for media='print', if there isn't, will be imported the normal css files. printContainer - Indicates if the original selector object must be included into the print (attention: setting it to false may breaks your css rules). operaSupport - Indicates if the plugin must support also Opera, in that case it provides to build a temporary tab to print.

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。