JS調(diào)用打印機功能簡單示例
本文實例講述了JS調(diào)用打印機功能的方法。分享給大家供大家參考,具體如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title><!--{$aListData.name}-->準(zhǔn)考證</title> <input id="btnPrint" type="button" value="打印" onclick="javascript:window.print();" /> <input id="btnPrint" type="button" value="打印預(yù)覽" onclick=preview(1) /> <style type="text/css" media=print> .noprint{display : none } </style> <script> function preview(oper) { if (oper < 10) { bdhtml=window.document.body.innerHTML;//獲取當(dāng)前頁的html代碼 sprnstr="<!--startprint"+oper+"-->";//設(shè)置打印開始區(qū)域 eprnstr="<!--endprint"+oper+"-->";//設(shè)置打印結(jié)束區(qū)域 prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //從開始代碼向后取html prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//從結(jié)束代碼向前取html window.document.body.innerHTML=prnhtml; window.print(); window.document.body.innerHTML=bdhtml; } else { window.print(); } } </script> <script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script> <script> jQuery(function($){ $("#closeButton").click(function(){ window.close(); }) }); </script> </head> <body> <a id='closeButton' title='Close' href="#" >關(guān)閉</a> <!-- 打印startprint與endprint之間的內(nèi)容--> <!--startprint1--> <h1>南京聾人高級中學(xué)2013年預(yù)科招生考試</h1> 姓名:<!--{$aListData.name}--><br/> 性別:<!--{$aListData.gender}--><br/> 畢業(yè)學(xué)校:<!--{$aListData.grschool}--><br/> 編號:<input type="text" name="sturegcard" class="input1 ml10" value="<!--{$aListData.sturegcard}-->"/><br/> 頭像:<img src="<!--{$aListData.avatar}-->" width="140"><br/> 考試日程:<br/> 地點:<br/> <!--{if $aRegExamsche}--> <!--{section name=data loop=$aRegExamsche}--> <!--{$aRegExamsche[data].date}--> <!--{$aRegExamsche[data].time}--> <!--{$aRegExamsche[data].lesson}--> <!--{$aRegExamsche[data].place}--><br/> <!--{/section}--> <!--{/if}--> <!--endprint1--> </body> </html>
更多關(guān)于JavaScript相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《JavaScript中json操作技巧總結(jié)》、《JavaScript切換特效與技巧總結(jié)》、《JavaScript查找算法技巧總結(jié)》、《JavaScript動畫特效與技巧匯總》、《JavaScript錯誤與調(diào)試技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》及《JavaScript數(shù)學(xué)運算用法總結(jié)》
希望本文所述對大家JavaScript程序設(shè)計有所幫助。
相關(guān)文章
ES6新特性二:Iterator(遍歷器)和for-of循環(huán)詳解
這篇文章主要介紹了ES6新特性二:Iterator(遍歷器)和for-of循環(huán),結(jié)合實例形式分析了ES6中Iterator(遍歷器)和for-of循環(huán)遍歷操作的相關(guān)實現(xiàn)技巧與注意事項,需要的朋友可以參考下2017-04-04JavaScript JSON.stringify()的使用總結(jié)
JSON是一種輕量級數(shù)據(jù)格式,可以方便地表示復(fù)雜數(shù)據(jù)結(jié)構(gòu)。JSON對象有兩個方法:stringify()和parse()。在簡單的情況下,這兩個方法分別可以將JavaScript序列化為JSON字符串,以及將JSON解析為原生JavaScript值。本文著重介紹JSON.stringify()的使用方法和注意事項。2021-05-05Bootstrap基本組件學(xué)習(xí)筆記之面板(14)
這篇文章主要為大家詳細介紹了Bootstrap基本組件學(xué)習(xí)筆記之面板,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-12-12超好玩js頁面效果之實現(xiàn)數(shù)值的動態(tài)變化
這篇文章主要給大家介紹了關(guān)于超好玩js頁面效果之實現(xiàn)數(shù)值的動態(tài)變化的相關(guān)資料,文中通過示例代碼及圖文介紹的非常詳細,對大家學(xué)習(xí)或者使用js具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2022-10-10Eclipse編輯jsp、js文件時卡死現(xiàn)象的解決辦法匯總
使用Eclipse編輯jsp、js文件時,經(jīng)常出現(xiàn)卡死現(xiàn)象,在網(wǎng)上百度了N次,經(jīng)過N次優(yōu)化調(diào)整后,卡死現(xiàn)象逐步好轉(zhuǎn),下面通過腳本之家平臺給大家分享幾種解決辦法,需要的朋友參考下2016-02-02ES6的函數(shù)rest參數(shù)使用小結(jié)
這篇文章主要介紹了ES6的函數(shù)rest參數(shù)用法,通過一個rest參數(shù)代替arguments變量的例子,對ES6?rest參數(shù)用法講解的非常詳細,需要的朋友可以參考下2023-08-08