web局部打印
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<script type="text/javascript">
function PrintSubPage(ContentId) {
var PrintWin = window.open('about:blank', 'Print');
PrintWin.document.write('<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>' + document.getElementById(ContentId).innerHTML);
//打印ContentId容器中的內容。
PrintWin.document.all.WebBrowser.ExecWB(7, 1);
PrintWin.close();
/*
WebBrowser.ExecWB(6,6) 直接打印
WebBrowser.ExecWB(8,1) 页面设置
WebBrowser.ExecWB(7,1) 打印预览*/
}
</script>
<body>
<form id="form1" runat="server">
2222222222不打印
<div>
<asp:Button ID="Button1" OnClientClick="PrintSubPage('div1');" runat="server" Style="left: 678px;
position: relative; top: 96px" Text="Button" />111111111111111111111不打印
<div id="div1" style="left: 0px; width: 521px; position: relative; top: 0px; height: 354px">
asdfsadfsadfsdaf会打印</div>
</div>
</form>
</body>
</html>
浙公网安备 33010602011771号