javascript 打印不显示按钮的方法


<style type="text/css">
@media print { 
 .noprint{display:none;}
}
</style>

<div align="right" class="noprint">
<input type="button"  value="打印" onclick= "window.print() " style="cursor:pointer;" />
</div>

 打印去掉页眉页脚和日期的脚本

function doPrint() {
        // 获得body的html
        bdhtml=window.document.body.innerHTML;
        // 打印开始的标志
        sprnstr="<!--startprint-->";
        // 打印结束的标志
        eprnstr="<!--endprint-->";
        // 从打印开始的位置截取到末尾
        prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
        // 从开始截取到打印结束的位置
        prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
        // 替换html
        window.document.body.innerHTML=prnhtml;
        // 打印
        window.print();
    }
 

猜你喜欢

转载自blog.csdn.net/Nep_tune/article/details/83828836
今日推荐