js print
来源:互联网 发布:ps10.0官方软件下载 编辑:程序博客网 时间:2024/06/10 15:58
介绍
参考
- 1、首先下载jquery.jqprint-0.3.js
- 2、 页面引入jquery.jqprint-0.3.js
- 3、js代码
<script type="text/javascript"> $(document).ready(function() { $("#btnPrint").click(function(){ jqprintDiv(); }); }); function jqprintDiv() { //打印初始化 if ($.browser.msie) { //IE浏览器执行 printitIE('content'); } else { //其他浏览器执行通用打印 $("#content").jqprint(); } } function printitIE(MyDiv) { setCload(); //提示窗口 if (confirm('确定打印吗?')) { var winname = window.open('', "_blank",''); var newstr = document.getElementById(MyDiv).innerHTML; var str = "<div style='position:absolute;padding-left: 50px;"; str+="padding-right: 50px;padding-top:50px;padding-bottom:50px;'>"; str+= newstr + "</div>"; winname.document.body.innerHTML= str; winname.print(); return false; } } //清空页眉页脚 function setCload(){ HKEY_Root="HKEY_CURRENT_USER"; HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"; var head,foot,top,bottom,left,right; try{ var Wsh=new ActiveXObject("WScript.Shell"); HKEY_Key="header"; //设置页眉(为空) 根据你自己要设置的填入 Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,""); HKEY_Key="footer"; //设置页脚(为空) 根据你自己要设置的填入 Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,""); HKEY_Key="margin_bottom"; //设置下页边距(0) 根据你自己要设置的填入 Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"200"); HKEY_Key="margin_left"; //设置左页边距(0) 根据你自己要设置的填入 Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"50"); HKEY_Key="margin_right"; //设置右页边距(0) Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"50"); HKEY_Key="margin_top"; //设置上页边距(8) Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"200"); }catch(e){ } } </script> <div class="float_cls" style="text-align:right;padding-top: 0px;" > <div style="text-align: right;margin-bottom: 0px;padding-right: 10px;"> <input type="hidden" id="leaderId" value="${id }"/> <input id="btnUpdate" class="btn btn-primary" type="button" value="编辑"/> <input id="btnPrint" class="btn btn-primary" type="button" value="打印"/> <input id="btnClose" class="btn btn-primary" type="button" value="关闭"/> </div> </div> <div id="content" style="padding-left:50px;padding-right:50px;padding-top: 50px; padding-bottom: 50px;"> ${ content } </div>[/codesyntax]
查看原文:http://surenpi.com/2017/01/20/js-print/
0 0
- js print
- js的pretty print
- JS print pdf
- 使用jQuery.print.js打印
- 原生js打印插件Print.js
- print >>
- Js:print the page 指定元素打印
- js window.print() 打印隐藏内容
- js打印window.print()图片打印
- js print打印网页指定区域内容
- 使用window.print()打印特定区域的JS代码
- js window.print实现打印特定控件或内容
- Raphael.js API之 Element.raphael,Paper.raphael,Paper.print()
- Highcharts JS去除Highcharts.com链接和print按钮
- springMVC返回数据的四种方式
- 对象持久化API之JPA入门教程
- DOS CMD
- Java基本概念-ajax
- Centos服务器被挂马的一次抓马经历
- js print
- pat-bl-1029
- POJ 2993-Emag eht htiw Em Pleh(模拟-根据棋子位置还原棋盘)
- YARN与MapReduce的区别
- PAT甲级1038
- JVM垃圾收集器(1)--G1之前GC方法概览
- Java基本概念-jQuery
- jvm理论-class 再重新认识一下class
- Docker命令大全