JS調(diào)用打印機(jī)功能簡單示例
本文實例講述了JS調(diào)用打印機(jī)功能的方法。分享給大家供大家參考,具體如下:
<!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é)運(yùn)算用法總結(jié)》
希望本文所述對大家JavaScript程序設(shè)計有所幫助。
相關(guān)文章
跟我學(xué)習(xí)javascript的嚴(yán)格模式
跟我學(xué)習(xí)javascript的嚴(yán)格模式,對javascript嚴(yán)格模式進(jìn)行概述,進(jìn)入嚴(yán)格模式的方法,以及如何調(diào)用和相關(guān)語法,感興趣的小伙伴們可以參考一下2015-11-11
通過javascript的匿名函數(shù)來分析幾段簡單有趣的代碼
想起自己很久以前學(xué)習(xí)javascript的經(jīng)歷,也曾經(jīng)碰到過幾個由匿名函數(shù)造成的困擾(其中一個就是由閉包引起的),下面就整理幾段簡單代碼討論一下,讓我們大家一起進(jìn)步。2010-06-06
JavaScript實現(xiàn)像雪花一樣的Hexaflake分形
這篇文章主要介紹了JavaScript實現(xiàn)像雪花一樣的Hexaflake分形,文中示例代碼非常詳細(xì),幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下2020-07-07
解決使用bootstrap的dropdown部件時報錯:error:Bootstrap dropdown require
這篇文章主要介紹了使用bootstrap的dropdown部件時報錯:error:Bootstrap dropdown require Popper.js ,小編把問題描述和解決方案分享給大家,需要的朋友可以參考下2018-08-08

