文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>js打印指定区域

js打印指定区域

时间:2010-07-19  来源:microjava

示例代码1
<html> 

<head></head> 

<script language=javascript> 

function doPrint() { 

bdhtml=window.document.body.innerHTML; 
sprnstr="<!--startprint-->"; 
eprnstr="<!--endprint-->"; 
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17); 
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); 
window.document.body.innerHTML=prnhtml; 
window.print(); 
} 
</script>

<body> 
  
   <!--startprint-->
   <div id="print">要打印的内容</div> 
   <!--endprint-->


<INPUT onclick="doPrint()" type="button" value="打印"/> 

<body> 

</html> 



示例代码2
<script>
function print(d){
for(i=0;i<4;i++){
if(i==d) eval("div"+i).style.visibility="visible";
else eval("div"+i).style.visibility="hidden";
}
document.all.wb.ExecWB(7,1);
for(i=0;i<4;i++){
eval("div"+i).style.visibility="visible";
}
}
</script>
<div id=div0>
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT> 
<input type=button value=打印预览 onclick="wb.execwb(7,1)">
<input type=button onClick=document.all.wb.ExecWB(6,1) value="打印">
<input type=button value=打印表格1 onclick=print("1")>
<input type=button value=打印表格2 onclick=print("2")>
<input type=button value=打印3 onclick=print("3")>
</div>

<div id=div1>
表格一:<br>
<table>
<tr><td>1111</td><td>1111</td><td>1111</td></tr>
<tr><td>1111</td><td>1111</td><td>1111</td></tr>
<tr><td>1111</td><td>1111</td><td>1111</td></tr>
</table>
</div>
<div id=div2>
表格二:<br>
<table>
<tr><td>2222</td><td>2222</td><td>2222</td></tr>
<tr><td>2222</td><td>2222</td><td>2222</td></tr>
<tr><td>2222</td><td>2222</td><td>2222</td></tr>
</table>
</div> 

<div id=div3>
测试文字3333
测试文字3333
测试文字3333
测试文字3333
</div>
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载