当前位置: 首页 > news >正文

网页打印——魔都千丝冥缘——未来之窗行业应用跨平台架构

 一、网页打印

网页打印优势,适用于跨平台,国产系统,windows,mac

不需要控件

二、打印效果

三、调用方法

 

  function 未来之窗_人工智能_打印指定区域(魔都id){var mode ="iframe";// "popup"; //iFrame //$("input[name='mode']:checked").val();var close =false;var extraCss=`<style> .cyberwinqr img{display: inline-block !important;}</style>`;var keepAttr = [];keepAttr.push( $("#"+魔都id).html() );var headElements = '<meta charset="utf-8" />,<meta http-equiv="X-UA-Compatible" content="IE=edge"/>' ;var print = "";print=$("#"+魔都id);var options = { mode : mode, popClose : close, extraCss : extraCss, retainAttr : keepAttr, extraHead : headElements };// $( print ).printArea( options );$( print ).东方仙盟_千丝冥缘_打印( options );}

四、打印技术代码

(function($){var counter=0;var modes={iframe:"iframe",popup:"popup"};var standards={strict:"strict",loose:"loose",html5:"html5"};var defaults={mode:modes.iframe,standard:standards.html5,popHt:500,popWd:400,popX:200,popY:200,popTitle:'',popClose:false,extraCss:'',extraHead:'',retainAttr:["id","class","style"]};var settings={};$.fn.东方仙盟_千丝冥缘_打印=function(options){$.extend(settings,defaults,options);counter++;var idPrefix="printArea_";$("[id^="+idPrefix+"]").remove();settings.id=idPrefix+counter;var $printSource=$(this);var东方仙盟_传送=未来之窗_东方仙盟_千丝冥缘_打印.getPrintWindow();未来之窗_东方仙盟_千丝冥缘_打印.write(东方仙盟_传送.doc,$printSource);setTimeout(function(){未来之窗_东方仙盟_千丝冥缘_打印.print(东方仙盟_传送)},1000)};var未来之窗_东方仙盟_千丝冥缘_打印={print:function(PAWindow){var paWindow=PAWindow.win;$(PAWindow.doc).ready(function(){paWindow.focus();paWindow.print();if(settings.mode==modes.popup&&settings.popClose)setTimeout(function(){paWindow.close()},2000)})},write:function(PADocument,$ele){PADocument.open();PADocument.write(未来之窗_东方仙盟_千丝冥缘_打印.docType()+"<html>"+未来之窗_东方仙盟_千丝冥缘_打印.getHead()+未来之窗_东方仙盟_千丝冥缘_打印.getBody($ele)+"</html>");PADocument.close()},docType:function(){if(settings.mode==modes.iframe)return"";if(settings.standard==standards.html5)return"<!DOCTYPE html>";var transitional=settings.standard==standards.loose?" Transitional":"";var dtd=settings.standard==standards.loose?"loose":"strict";return'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01'+transitional+'//EN" "http://www.w3.org/TR/html4/'+dtd+'.dtd">'},getHead:function(){var extraHead="";var links="";if(settings.extraHead)settings.extraHead.replace(/([^,]+)/g,function(m){extraHead+=m});$(document).find("link").filter(function(){var relAttr=$(this).attr("rel");return($.type(relAttr)==='undefined')==false&&relAttr.toLowerCase()=='stylesheet'}).filter(function(){var mediaAttr=$(this).attr("media");return $.type(mediaAttr)==='undefined'||mediaAttr==""||mediaAttr.toLowerCase()=='print'||mediaAttr.toLowerCase()=='all'}).each(function(){links+='<link type="text/css" rel="stylesheet" href="'+$(this).attr("href")+'" >'});if(settings.extraCss)settings.extraCss.replace(/([^,\s]+)/g,function(m){links+='<link type="text/css" rel="stylesheet" href="'+m+'">'});return"<head><title>"+settings.popTitle+"</title>"+extraHead+links+"</head>"},getBody:function(elements){var htm="";var attrs=settings.retainAttr;elements.each(function(){var ele=未来之窗_东方仙盟_千丝冥缘_打印.getFormData($(this));var attributes=""for(var x=0;x<attrs.length;x++){var eleAttr=$(ele).attr(attrs[x]);if(eleAttr)attributes+=(attributes.length>0?" ":"")+attrs[x]+"='"+eleAttr+"'"}htm+='<div '+attributes+'>'+$(ele).html()+'</div>'});return"<body>"+htm+"</body>"},getFormData:function(ele){var copy=ele.clone();var copiedInputs=$("input,select,textarea",copy);$("input,select,textarea",ele).each(function(i){var typeInput=$(this).attr("type");if($.type(typeInput)==='undefined')typeInput=$(this).is("select")?"select":$(this).is("textarea")?"textarea":"";var copiedInput=copiedInputs.eq(i);if(typeInput=="radio"||typeInput=="checkbox")copiedInput.attr("checked",$(this).is(":checked"));else if(typeInput=="text")copiedInput.attr("value",$(this).val());else if(typeInput=="select")$(this).find("option").each(function(i){if($(this).is(":selected"))$("option",copiedInput).eq(i).attr("selected",true)});else if(typeInput=="textarea")copiedInput.text($(this).val())});return copy},getPrintWindow:function(){switch(settings.mode){case modes.iframe:var f=new未来之窗_东方仙盟_千丝冥缘_打印.Iframe();return{win:f.contentWindow||f,doc:f.doc};case modes.popup:var p=new未来之窗_东方仙盟_千丝冥缘_打印.Popup();return{win:p,doc:p.doc}}},Iframe:function(){var frameId=settings.id;var iframeStyle='border:0;position:absolute;width:0px;height:0px;right:0px;top:0px;';var iframe;try{iframe=document.createElement('iframe');document.body.appendChild(iframe);$(iframe).attr({style:iframeStyle,id:frameId,src:"#"+new Date().getTime()});iframe.doc=null;iframe.doc=iframe.contentDocument?iframe.contentDocument:(iframe.contentWindow?iframe.contentWindow.document:iframe.document)}catch(e){throw e+". iframes may not be supported in this browser.";}if(iframe.doc==null)throw"Cannot find document.";return iframe},Popup:function(){var windowAttr="location=yes,statusbar=no,directories=no,menubar=no,titlebar=no,toolbar=no,dependent=no";windowAttr+=",width="+settings.popWd+",height="+settings.popHt;windowAttr+=",resizable=yes,screenX="+settings.popX+",screenY="+settings.popY+",personalbar=no,scrollbars=yes";var newWin=window.open("","_blank",windowAttr);newWin.doc=newWin.document;return newWin}}})(jQuery);

五、阿雪技术观


拥抱开源与共享,见证科技进步奇迹,畅享人类幸福时光!

让我们积极投身于技术共享的浪潮中,不仅仅是作为受益者,更要成为贡献者。无论是分享自己的代码、撰写技术博客,还是参与开源项目的维护和改进,每一个小小的举动都可能成为推动技术进步的巨大力量


http://www.mrgr.cn/news/53499.html

相关文章:

  • 滑动窗口-无重复字符的最长字串
  • vscode open editors 打开
  • 写论文节省论文页面空间的办法
  • latex常见长度单位
  • 第一百零七周周报
  • 如何保护您的服务器免受 POODLE SSLv3 漏洞的影响
  • wpf grid 的用法
  • WordPress任推帮网盘拉新数据统计插件
  • Miniconda管理虚拟环境【Python环境配置】
  • HDU RealPhobia
  • Spring实现3种异步流式接口,解决接口超时烦恼
  • Apple Vision Pro市场表现分析:IDC最新数据揭示的真相
  • 郑州大学第一附属医院许建中教授专家团队会诊室揭牌仪式在郑州长江中医院成功举行
  • 华为杯”第十三届中国研究生数学建模竞赛-E题:基于多目标规划和智能优化算法的粮食最低收购价政策研究(中)
  • LLM 的推理优化技术纵览
  • C++类的构造函数
  • 如何安装MySql
  • JavaWeb 23.NPM配置和使用
  • 【数据分享】中国历史学年鉴(1979-2001)
  • [创业之路-154] :图解:结构需求分析、结构设计、加工、生产的整个流程与常见问题