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>

 

posted @ 2017-03-29 11:29  侠岚之弋痕夕  阅读(278)  评论(1编辑  收藏  举报
Where is the starting point, we don't have a choice, but the destination where we can pursue!