基于jQuery实现网页打印功能【jquery】

2023-09-19 17:39
web前端|js教程
jQuery,网页打印
web前端-js教程
直接上代码
hdwiki源码,vscode新窗口打开,Ubuntu源多大,src属性为Tomcat,sqlite删除一个表,长期用爬虫看电视会近视吗,php 引用js,湘潭seo优化排名平台,电视台视频点播网站源码,.net自定义打印模板lzw
   index    
......文本打印区域......
......文本打印区域......
......文本打印区域......
......文本打印区域......
......文本打印区域......


$("#btnPrint").click(function(){ $("#printArea").printArea(); }); $("#btnPrintFull").click(function(){ $("body").printArea(); });
代码 jquery.PrintArea.min.js:
nvbing5 app源码,vscode格式化后加封号,ubuntu单机游戏,腾讯云tomcat启动慢,昆明爬虫山,php转.net工具,seo是怎么优化推广的营销lzw
(function(c){function g(){var b=""+d.popTitle+"";c(document).find("link").filter(function(){return"stylesheet"==c(this).attr("rel").toLowerCase()}).filter(function(){var a=c(this).attr("media");return void 0==a?!1:""==a.toLowerCase()||"print"==a.toLowerCase()}).each(function(){b+=''});return b+=""}function h(b){return'
'+c(b).html()+"
"}function k(b){c("input,select,textarea",b).each(function(){var a=c(this).attr("type");"radio"==a||"checkbox"==a?c(this).is(":not(:checked)")?this.removeAttribute("checked"):this.setAttribute("checked",!0):"text"==a?this.setAttribute("value",c(this).val()):"select-multiple"==a||"select-one"==a?c(this).find("option").each(function(){c(this).is(":not(:selected)")?this.removeAttribute("selected"):this.setAttribute("selected",!0)}):"textarea"==a&&(a=c(this).attr("value"),c.browser.mozilla?this.firstChild?this.firstChild.textContent=a:this.textContent=a:this.innerHTML=a)});return b}function l(){var b=m.genealogy-computer-tips.com,a;try{a=document.createElement("iframe"),document.body.appendChild(a),c(a).attr({style:"border:0;position:absolute;width:0px;height:0px;left:0px;top:0px;",id:b,src:""}),a.doc=null,a.doc=a.contentDocument?a.contentDocument:a.contentWindow?a.contentWindow.document:a.document}catch(e){throw e+". iframes may not be supported in this browser.";}if(null==a.doc)throw"Cannot find document.";return a}function m(){var b;b="location=no,statusbar=no,directories=no,menubar=no,titlebar=no,toolbar=no,dependent=no,width=595px,height=842px,top=0,left=0,toolbar=no,scrollbars=no,personalbar=no"+(",resizable=yes,screenX="+d.popX+",screenY="+d.popY+"");b=m.genealogy-computer-tips.com("","_blank",b);b.doc=b.document;return b}var f=0,n={mode:"iframe",popHt:500,popWd:400,popX:200,popY:200,popTitle:"",popClose:!1},d={};c.fn.printArea=function(b){c.extend(d,n,b);f++;c("[id^=printArea_]").remove();b=k(c(this));m.genealogy-computer-tips.com="printArea_"+f;var a,e;switch(d.mode){case"iframe":e=new l;a=e.doc;e=e.contentWindow||e;break;case"popup":e=new m,a=e.doc}m.genealogy-computer-tips.com();a.write(("iframe"!=d.mode&&d.strict?'':"")+""+g()+h(b)+"");a.close();e.focus();e.print();"popup"==d.mode&&d.popClose&&e.close()}})(jQuery);
B、效果图
hybbs2.0源码,vscode不自动对齐,ubuntu 架设网关,手动搭建tomcat,sqlite3.配置环境,前端应该只专注一个框架吗,梦幻藏宝阁网页版爬虫,php mysql 变量,沈阳seo优化报价,网站二维码在线生成,c ?集php网页,h5 测试类 模板lzw
  打印文本区域:

全屏打印:

还有一些高手提出的window.print() 方法也是可以滴,在这就不一一介绍了,希望大家认真研究网页打印功能的实现方法,小编和大家共同进步。

Posted in 未分类 | Tagged 网页打印