码迷,mamicode.com
首页 > Web开发 > 详细

js实现打印

时间:2015-04-23 10:53:55      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<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>

<title>div print</title>

</head>

<body>

<input type="button" onClick="printdiv(‘div_print‘);" value=" 打印 ">

<div id="div_print">

<h1 style="Color:Red">被打印区域:www.phpernote.com</h1>

</div>

这块区域是打印不到的!

</body>

</html>

 

js实现打印

标签:

原文地址:http://www.cnblogs.com/renshi/p/4449663.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!