好记性不如烂键盘
原文地址:http://blog.csdn.net/leytton/article/details/38612973
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<script type="text/javascript">
function printWin(content_id)
{
var oWin=window.open("","_blank");
oWin.document.write(document.getElementById(content_id).innerHTML);
oWin.focus();
oWin.document.close();
oWin.print()
oWin.close()
}
</script>
<div>
JS局部打印
</div>
<div id="content">
这里是打印内容
</div>
<hr size="1">
<div>
<button onclick="printWin('content')" >局部打印</button>
<button onclick="window.print();" >整页打印</button>
</div>
</body>
</html>