---
title: "web页面打印"
author: "yaofeng911"
date: "2012-04-26T14:25:44Z"
tags: []
categories: ["Web前端"]
slug: "web"
draft: false
lastmod: "2012-04-26T14:31:03Z"
id: 1499786
url: "https://yaofeng911.iteye.com/blog/1499786"
---

Web页面打印:

 

\[code="html"]

function printsetup(){  
// 打印页面设置 页面需引入 &lt;OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=3&gt;&lt;/OBJECT&gt;  
wb.execwb(8,1);  
}

function printpreview(){  
// 打印页面预览  
wb.execwb(7,1);  
}

function printit(div) {  
if (confirm("确定打印吗？")) {  
document.getElementById(div).style.display = "none";//不用打印的元素隐藏  
wb.execwb(6, 6);  
}  
document.getElementById(div).style.display = "";  
}

function closeWin() {  
window.opener=null;window.open('','\_self');window.close();  
}

function goTop() {  
$('html, body').animate({scrollTop:0}, 'slow');  
}

\[/code]

 

html页面引入：

\[code="html"]

&lt;OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=3&gt;&lt;/OBJECT&gt;

&lt;div align="center" id="printBT"&gt;  
&lt;input type="button" value="打印" onclick="javascript:printit('printBT');" class="btnopr"/&gt;  
&lt;input type="button" value="关闭" onclick="javascript:closeWin();" class="btnopr"/&gt;  
&lt;/div&gt;

\[/code]