JS實現打印功能

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>中國綠色廚房計劃</title>
<script language=javascript>     
function printsetup(){
    //  打印頁面設置
    wb.execwb(8,1);   
}
function printpreview(){
    //  打印頁面預覽
    wb.execwb(7,1);
}
function printit(){
  if (confirm('確定打印嗎?')){
    wb.ExecWB(6,1)
    //wb.execwb(1,1)//打開
    //wb.ExecWB(2,1);//關閉現在所有的IE窗口,並打開一個新窗口
    //wb.ExecWB(4,1)//;保存網頁
    //wb.ExecWB(6,1)//打印
    //wb.ExecWB(7,1)//打印預覽
    //wb.ExecWB(8,1)//打印頁面設置
    //wb.ExecWB(10,1)//查看頁面屬性
    //wb.ExecWB(15,1)//好像是撤銷,有待確認
    //wb.ExecWB(17,1)//全選
    //wb.ExecWB(22,1)//刷新
    //wb.ExecWB(45,1)//關閉窗體無提示
  }
}
</script> 
</head>
<body>
<div style="width:640px;height:20px;margin:100px auto 0 auto;font-size:12px;text-align:right;">
        <input value="打印" type="button" onclick="javascript:window.print()" />
        <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" id="wb" name="wb" width="0">
        </OBJECT>
        <input type=button name=button_print style="display:none;" value="打印本單據" onclick="javascript:printit()">
        <input type=button name=button_setup value="打印頁面設置" onclick="javascript:printsetup();">
        <input type=button name=button_show value="打印預覽" onclick="javascript:printpreview();">
        <input type=button name=button_fh value="關閉" onclick="javascript:window.close();">
</div>
<div style="width:640px;height:624px;margin:20px auto;">
  <img src="images/money.jpg" />
</div>
</body>
</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章