Home >Backend Development >PHP Tutorial >php 实现打印预览的功能

php 实现打印预览的功能

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:32:052806browse

.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