js print
-
介紹
-
參考
- 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/
相關文章
- JavaScript print()JavaScript
- Print流
- 前端網頁列印外掛print.js(可匯出pdf)前端網頁JS
- python print 用法Python
- 字串函式 print ()字串函式
- print基礎用法
- 655-Print Binary Tree
- pycharm print 加顏色PyCharm
- print 與 println 的區別
- WPF open image and print as pdf file
- python3 print報錯Python
- Print輸出顏色字型方法
- python ruturn 和 print 的區別Python
- exclude Log4j print Log
- python3.6print怎麼用Python
- [js]使用瀏覽器列印事件window.print()設定橫向;列印時新增分頁標記JS瀏覽器事件
- Python 3 進階 —— print 列印和輸出Python
- window.print —— 瀏覽器列印掃盲瀏覽器
- 使用pycharm print不輸出怎麼辦PyCharm
- 陣列對換,print函式傳參陣列函式
- 如何用python3輸出print對齊?Python
- PHP中的輸出:echo、print、printf、sprintf、pPHP
- python3中 print不加括號報錯!Python
- 自帶的 print 函式居然會報錯?函式
- Flutter冷知識 | 獲取dart的print內容FlutterDart
- Python print函式引數詳解以及效果展示Python函式
- python的print函式不要換行怎麼寫Python函式
- 簡單介紹python的input,print,eval函式Python函式
- 告別Print,使用IceCream進行高效的Python除錯Python除錯
- python中print()有什麼用?常用引數有哪些?Python
- 一個後臺靜態模板,自帶excel,print,cvsExcel
- @media print可以用來控制web列印樣式嗎?Web
- pythn print格式化輸出———“%s 和 % d” 都是什麼意思?
- GitHub 熱門:別再用 print 輸出來除錯程式碼了Github除錯
- Pytnon變數print列印計數顯示前面補零 0001、0002變數
- python迴圈遍歷字典: title_content_list.append([key, value])print(tiPythonAPP
- Python print函式控制檯中文輸出16進位制問題Python函式
- 好程式設計師Python學習路線分享用pprint代替print程式設計師Python
- SwiftUI 如何在介面中print列印日誌log (EmptyView教程含原始碼)SwiftUIView原始碼