致力于技术进步

专注于编程艺术

博客园 首页 新随笔 联系 订阅 管理
<script language="javascript">
   function printPreview()  //将 DataGrid 打印预览
   {
   try
   {
    var printWindow = window.open("","_blank");
    var str = "<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>"
    var s = "<html>\r\n";
    s += "<head>";
     
    s += "<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>";
    s += "</head>";
    s += "<body><center><br/>";
    s += "<div align=center style='width:96%'>";
    s += document.all.DataGrid1.outerHTML;
    s += "</div>";
    s += "</center></body>";
    s += "</html>";
    printWindow.document.write(s);
    printWindow.document.close();
    printWindow.document.body.insertAdjacentHTML("beforeEnd", str);
    printWindow.document.all.WebBrowser.ExecWB(7,1);  //打印预览
    //printWindow.document.all.WebBrowser.ExecWB(6,6);//直接打印
    printWindow.close();
   }
   catch(e)
   {
    alert("您的浏览器版本太低,请升级您的浏览器!");
   }
   }
  </script>
posted on 2007-12-10 12:04  stephen&amp;#183;周  阅读(126)  评论(0)    收藏  举报