Javascript简单打印与导出

<script language="JavaScript">
function PrintTable(Id){
 var mStr;
 mStr = window.document.body.innerHTML ;
 var mWindow = window;  
 window.document.body.innerHTML =Id.innerHTML;
 mWindow.print();
 window.document.body.innerHTML = mStr;
}
function saveas(Id){
  var mStr;
  mStr = window.document.body.innerHTML ;
  var mWindow = window;  
  window.document.body.innerHTML =Id.innerHTML;
  document.write(window.document.body.innerHTML);
  document.execCommand("saveAs","1","查询结果.xls");
  window.document.body.innerHTML = mStr;
  history.back();
}
</script>
posted @ 2008-09-23 16:07  joinger  阅读(208)  评论(0编辑  收藏  举报