Home  >  Article  >  Backend Development  >  php 实现打印预览的效能

php 实现打印预览的效能

WBOY
WBOYOriginal
2016-06-13 12:22:28861browse

php 实现打印预览的功能

.noprint{display : none}

不需要打印的地方

<script></script>

functionpreview(oper)

{

if (oper

{

bdhtml=window.document.body.innerHTML;//获取当前页的html代码

sprnstr="";//设置打印开始区域

eprnstr="";//设置打印结束区域

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();

}

}

XXXXX

要打印的内容

.noprint{display : none}

不需要打印的地方

<script></script>

functionpreview(oper)

{

if (oper

{

bdhtml=window.document.body.innerHTML;//获取当前页的html代码

sprnstr="";//设置打印开始区域

eprnstr="";//设置打印结束区域

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();

}

}

XXXXX

要打印的内容

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn