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>


你可能感兴趣的:(js,打印,局部打印,整页打印)