百度
360搜索
搜狗搜索

怎样用php实现打印预览的功能详细介绍

  下面是php实现打印预览的功能的代码:

<inputid="btnPrint" type="button" value="打印"onclick="javascript:window.print();" />
<inputid="btnPrint" type="button" value="打印预览" onclick=preview(1)/>
<styletype="text/css" media=print>
.noprint{display : none}
</style>
<pclass="noprint">不须要打印的地方</p>
<script>
functionpreview(oper)
{
if (oper <10)
{
bdhtml=window.document.body.innerHTML;//获取当前页的html代码
sprnstr="<!�Cstartprint"+oper+"�C>";//设置打印�_始区域
eprnstr="<!�Cendprint"+oper+"�C>";//设置打印结束区域
prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18);//从�_始代码向后取html
prnhtmlprnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
window.document.body.innerHTML=prnhtml;
window.print();
window.document.body.innerHTML=bdhtml;
} else {
window.print();
}
}
</script>
<p>XXXXX</p>
<!�Cstartprint1�C>要打印的内容<!�Cendprint1�C>
<inputid="btnPrint" type="button" value="打印"onclick="javascript:window.print();" />
<inputid="btnPrint" type="button" value="打印预览" onclick=preview(1)/>
<styletype="text/css" media=print>
.noprint{display : none}
</style>
<pclass="noprint">不须要打印的地方</p>
<script>
functionpreview(oper)
{
if (oper <10)
{
bdhtml=window.document.body.innerHTML;//获取当前页的html代码
sprnstr="<!�Cstartprint"+oper+"�C>";//设置打印�_始区域
eprnstr="<!�Cendprint"+oper+"�C>";//设置打印结束区域
prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18);//从�_始代码向后取html
prnhtmlprnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
window.document.body.innerHTML=prnhtml;
window.print();
window.document.body.innerHTML=bdhtml;
} else {
window.print();
}
}
</script>
<p>XXXXX</p>
<!�Cstartprint1�C>要打印的内容<!�Cendprint1�C>

阅读更多 >>>  免费源码资源网站

网站数据信息

"怎样用php实现打印预览的功能"浏览人数已经达到30次,如你需要查询该站的相关权重信息,可以点击进入"Chinaz数据" 查询。更多网站价值评估因素如:怎样用php实现打印预览的功能的访问速度、搜索引擎收录以及索引量、用户体验等。 要评估一个站的价值,最主要还是需要根据您自身的需求,如网站IP、PV、跳出率等!