日期:2014-05-18 浏览次数:20395 次
<script language="javascript" type ="text/javascript"> function preview() { bdhtml=window.document.body.innerHTML; sprnstr="<!--startprint-->"; eprnstr="<!--endprint-->"; prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17); prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr)); window.document.body.innerHTML=prnhtml; window.print(); } function winClose() { window.close(); } </script>
------解决方案--------------------
JScript code
----------------------------------------
<script language="javascript">
<!--
function PrintNote()
{
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.all("PrintContent").innerHTML);
PrintWin.document.all.WebBrowser.ExecWB(7,1);
PrintWin.close();
}
-->
</script>
--------------------------------------------
内容用<div>装起来,并把DIV设置ID
<div id="PrintContent" align="center">
your GridView
</div>
把gridvie控件放入DIV里就可以实现打印了。
------解决方案--------------------