欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

js或jquery實(shí)現(xiàn)頁(yè)面打印可局部打印

 更新時(shí)間:2014年03月27日 15:38:57   作者:  
這篇文章主要介紹了js或jquery如何實(shí)現(xiàn)頁(yè)面打印也可局部打印,需要的朋友可以參考下
js或jquery實(shí)現(xiàn)頁(yè)面打印(局部打印)

1、js實(shí)現(xiàn)(可實(shí)現(xiàn)局部打印)
復(fù)制代碼 代碼如下:

<html>
<title>js打印</title>
<head></head><body>
<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>


<p class="noprint">不需要打印的地方</p>

<script>
function preview(oper)
{
if (oper < 10)
{
bdhtml=window.document.body.innerHTML;//獲取當(dāng)前頁(yè)的html代碼
sprnstr="<!--startprint"+oper+"-->";//設(shè)置打印開(kāi)始區(qū)域
eprnstr="<!--endprint"+oper+"-->";//設(shè)置打印結(jié)束區(qū)域
prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //從開(kāi)始代碼向后取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>
<p>XXXXX</p>
<!--startprint1-->要打印的內(nèi)容<!--endprint1-->
</body>
</html>

2、調(diào)用windows底層打印,報(bào)安全警告,不建議使用(不支持局部打印)
復(fù)制代碼 代碼如下:

<HTML>
<HEAD>
<TITLE>javascript打印-打印頁(yè)面設(shè)置-打印預(yù)覽代碼</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312" />
<SCRIPT language=javascript>
  function printsetup(){
  // 打印頁(yè)面設(shè)置
  wb.execwb(8,1);
  }
  function printpreview(){
  // 打印頁(yè)面預(yù)覽
    
  wb.execwb(7,1);      
    
  }

  function printit()
  {
  if (confirm('確定打印嗎?')) {
  wb.execwb(6,6);
  }
  }
  </SCRIPT>
</HEAD>
<BODY>

<DIV align=center>
<OBJECT id=wb height=0 width=0
classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 name=wb></OBJECT>
<INPUT onclick=javascript:printit() type=button value=打印 name=button_print />
<INPUT onclick=javascript:printsetup(); type=button value=打印頁(yè)面設(shè)置 name=button_setup />
<INPUT onclick=javascript:printpreview(); type=button value=打印預(yù)覽 name=button_show />
一按開(kāi)始的減肥了卡時(shí)間段
</DIV>
</BODY>
</HTML>

3、jQuery實(shí)現(xiàn)(支持局部打?。?
復(fù)制代碼 代碼如下:

<html>
<head>
<script type="text/javascript" src="jquery-1.6.4.js"></script>
<script>
$(function(){
$("input#biuuu_button").click(function(){
$("div#myPrintArea").printArea();
});
</script>
</head>
<body>
<input id="biuuu_button" type="button" value="打印"></input>
<div id="myPrintArea">.....文本打印部分.....</div> <div class="quote_title">引用</div><div class="quote_div"></div>
</body>
</html>

相關(guān)文章

最新評(píng)論