jquery.jqprint-0.3.js打印页面
来源:互联网 发布:手机关屏幕软件 编辑:程序博客网 时间:2024/05/17 23:18
可能打印网页中的数据有多种方法,我使用的是jquery.jprint-0.3.js的方法,使用方法如下,
比较简单,
在js里边添加函数,
button:[{name: '打印', callback: function () { /*打印*/ $('.consulting_project_form').jqprint({ debug: false, importCSS: true, printContainer: true, operaSupport: false }); return false }}],
即可,
然后调用jquery.jqprint-0.3.js中的方法就能打印出相应的页面,在打印的时候,页面中会出现网页标题以及网页链接,可以在浏览器中进行设置。
jquery.jqprint-0.3.js中的源码:
、
// -----------------------------------------------------------------------// Eros Fratini - eros@recoding.it// jqprint 0.3//// - 19/06/2009 - some new implementations, added Opera support// - 11/05/2009 - first sketch//// Printing plug-in for jQuery, evolution of jPrintArea: http://plugins.jquery.com/project/jPrintArea// requires jQuery 1.3.x//// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php//------------------------------------------------------------------------(function($) { var opt; $.fn.jqprint = function (options) { opt = $.extend({}, $.fn.jqprint.defaults, options); var $element = (this instanceof jQuery) ? this : $(this); if (opt.operaSupport && $.browser.opera) { var tab = window.open("","jqPrint-preview"); tab.document.open(); var doc = tab.document; } else { var $iframe = $("<iframe />"); if (!opt.debug) { $iframe.css({ position: "absolute", width: "0px", height: "0px", left: "-600px", top: "-600px" }); } $iframe.appendTo("body"); var doc = $iframe[0].contentWindow.document; } if (opt.importCSS) { if ($("link[media=print]").length > 0) { $("link[media=print]").each( function() { doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' media='print' />"); }); } else { $("link").each( function() { doc.write("<link type='text/css' rel='stylesheet' href='" + $(this).attr("href") + "' />"); }); } } if (opt.printContainer) { doc.write($element.outer()); } else { $element.each( function() { doc.write($(this).html()); }); } doc.close(); (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).focus(); setTimeout( function() { (opt.operaSupport && $.browser.opera ? tab : $iframe[0].contentWindow).print(); if (tab) { tab.close(); } }, 1000); } $.fn.jqprint.defaults = {debug: false,importCSS: true, printContainer: true,operaSupport: true}; // Thanks to 9__, found at http://users.livejournal.com/9__/380664.html jQuery.fn.outer = function() { return $($('<div></div>').html(this.clone())).html(); } })(jQuery);
0 0
- jquery.jqprint-0.3.js打印页面
- jquery.jqprint.js 实现打印
- jqprint页面打印
- jQuery打印插件JQPRINT
- jQuery打印插件jqprint
- jQuery打印插件jqprint
- jQuery打印插件JQPrint
- jQuery打印插件jqprint
- Jqprint 轻量级页面打印插件
- jQuery-jqprint实现打印功能
- Jquery Jqprint—借助Jquery Jqprint实现网页打印功能
- 简单的jQuery.jqprint插件实现打印HTML页面,页面导出为PDF文件
- 使用jqprint插件完成页面打印
- html 页面实现打印(jqprint)
- JQPRINT-不错的jquery打印插件
- jquery的一个打印插件jqPrint
- 利用JQuery jqprint实现打印功能
- Jquery- Jqprint实现网页打印功能
- Linux - scp服务器文件传送命令
- 秋招总结
- 4245: KI的斐波那契 递归
- Hadoop集群实践-完整Hadoop分布式集群部署ubuntu-16.04.1+hadoop-2.7.3
- 机器学习
- jquery.jqprint-0.3.js打印页面
- Mysql备份与恢复
- mybatis的熟练运用以及反射知识讲解
- POJ 3080 Blue Jeans
- python之数据库sqlite3
- 通达OA 常用代码整理(陆续补充)
- 关于静态库/动态库,那些你必须要踩的坑
- 学习笔记:DEMO-成品网页1
- 动态改变log4j的级别(level)