我写了这段代码,但仍然打印预览选项......
this.contentWindow.print()
用于打印目的
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script>
function printPage()
{
var div = document.getElementById("printerDiv");
div.innerHTML = '<iframe src="PrintDemo.aspx" onload="this.contentWindow.print();"></iframe>';
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<button onclick="printPage()">prin`enter code here`t</button>
<div id="printerDiv" ">
This Page Is for print demo`enter code here`
</div>
</div>
</form>
</body>
</html>