首页 > 代码库 > javascript实现打印功能

javascript实现打印功能

<input name="b_print" type="button" class="ipt" onClick="printdiv(‘div_print‘);" value="点击打印预约书详情" style="width: 100%;height: 40px;background: #fff;border:0;border-bottom: 1px solid #d3d7db; ">
<div class="contentpanel" id="div_print">
*****************
</div>

<script language="javascript">
        function printdiv(printpage) {
            var headstr = "<html><head><title></title></head><body>";
            var footstr = "</body>";
            var newstr = document.all.item(printpage).innerHTML;
            var oldstr = document.body.innerHTML;
            document.body.innerHTML = headstr + newstr + footstr;
            window.print();
            document.body.innerHTML = oldstr;
            return false;
        }
</script>

 

javascript实现打印功能