JS的局部打印与整页打印

【转载请注明出处: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>


posted @ 2014-08-16 14:05  Leytton  阅读(250)  评论(0编辑  收藏  举报