在WEB中,怎么调用打印功能?
解决方案 »
- Gridview导出EXCEL问题 急~~~!!!
- “未将对象引用设置到对象的实例。”,Comobox
- 有一个特殊需求,关于datatable的,望有经验的高手给予帮助
- 求高手指点,给数组赋值
- 普通窗体模仿MDI窗体工作。
- 【在线等,急!】对获得的中文数据的首字母,按要求进行排列
- 在C#中TextBox里面附一个值来删除TreeView的某一个节点,怎么写啊。
- 在2005下是好好的,俺拷到IIS下就不行了,俺是新手
- C# socket.handler 的问题
- 可以在vs.net中可视化编写xml文件吗??
- 请介绍一个C#的C/S的开源代码,想学习C/S编程,最好是2.0的
- 求windos文本编辑器里加一段“查找”的选项代码
可以打印,不过不知道能不能实现搂主的要求
www.wave12.com
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>客户网络开通</title>
<link href="../css/manage.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<Script language="JavaScript">
var hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\\\\Software\\\\Microsoft\\\\Internet Explorer\\\\PageSetup\\\\"
// 设置页眉页脚为空
function PageSetup_Null()
{
try{
var RegWsh = new ActiveXObject("WScript.Shell") ;
hkey_key="header" ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"") ;
hkey_key="footer" ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"") ;
}
catch(e){}
}
// 设置页眉页脚为默认值
function PageSetup_Default()
{
try{
var RegWsh = new ActiveXObject("WScript.Shell") ;
hkey_key="header" ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P") ;
hkey_key="footer" ;
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d") ;
}
catch(e){}
}
// 打印
function PrintPage()
{
PageSetup_Null();
document.getElementById('btnSub').style.display = "none";
document.getElementById('btnBack').style.display = "none";
document.getElementById('subLine').style.display = "none";
wb.execwb(6,1);
PageSetup_Default();
}
</Script>
<style type="text/css"> .STYLE1 { FONT-SIZE: 12pt; COLOR: #0066ff } </style>
</HEAD>
<body>
<object classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=WB name=wb width=0 VIEWASTEXT></object>
<form id="Form1" method="post" runat="server">
<table width="380" bgcolor="gainsboro" cellSpacing="0" cellPadding="0" align="center" border="0">
<tr>
<td>
<table width="100%" cellSpacing="1" cellPadding="2" border="0" align="center">
<tr bgcolor="white">
<td height="25" colspan="2" align="center" valign="middle"><span class="STYLE1">房间[<%=room%>]网络访问帐号</span></td>
</tr>
<tr bgcolor="white">
<td width="40%" height="25" align="right" valign="middle">登录帐号:</td>
<td><INPUT id="txtRoom" type="text" readonly name="txtRoom" runat="server"></td>
</tr>
<tr bgcolor="white">
<td height="25" align="right" valign="middle">登录密码:</td>
<td><INPUT id="txtPass" type="text" name="txtPass" readonly runat="server"></td>
</tr>
<tr id="subLine" bgcolor="white">
<td height="25" colspan="2" align="center" valign="middle"><INPUT id="btnSub" type="button" onclick="PrintPage();" value=" 打 印 ">
<INPUT id="btnBack" type="submit" value=" 返 回 " runat="server"></td>
</tr>
<TR bgcolor="white">
<TD vAlign="middle" align="center" colSpan="2" height="25"><STRONG><FONT color="#990033">说明:房间号码即为登录ID,请妥善保管您的上网帐号!</FONT></STRONG></TD>
</TR>
</table>
</td>
</tr>
</table>
<table align="center">
<tr>
<td height="200" width="98%" valign="bottom" align="center"><strong>--------------------------------------------------------------------------------<br>
欢迎使用本酒店上网服务,请妥善保管您的上网帐号!</strong></td>
</tr>
</table>
</form>
</body>
</HTML>
<p style="page-break-after:always">page2</p>
//设置打印
<object id="factory" style="display:none" viewastext
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360"
></object>
<input type=button value=页面设置 onclick="factory.printing.PageSetup()">
<input type=button value=打印预览 onclick="factory.printing.Preview()">
<script language=javascript>
function window.onload()
{
// -- advanced features
factory.printing.SetMarginMeasure(2) // measure margins in inches
factory.printing.SetPageRange(false, 1, 3) // need pages from 1 to 3
factory.printing.printer = "HP DeskJet 870C"
factory.printing.copies = 2
factory.printing.collate = true
factory.printing.paperSize = "A4"
factory.printing.paperSource = "Manual feed"
// -- basic features
factory.printing.header = "居左显示&b居中显示&b居右显示页码,第&p页/共&P页"
factory.printing.footer = "(自定义页脚)"
factory.printing.portrait = false
factory.printing.leftMargin = 0.75
factory.printing.topMargin = 1.5
factory.printing.rightMargin = 0.75
factory.printing.bottomMargin = 1.5
}
function Print(frame) {
factory.printing.Print(true, frame) // print with prompt
}
</script>
<input type=button value="打印本页" onclick="factory.printing.Print(false)">
<input type=button value="页面设置" onclick="factory.printing.PageSetup()">
<input type=button value="打印预览" onclick="factory.printing.Preview()"><br>
<a href="http://www.meadroid.com/scriptx/docs/printdoc.htm?static" target=_blank>具体使用手册,更多信息,点这里</a>
//自带的打印预览 WebBrowser.ExecWB(1,1) 打开
Web.ExecWB(2,1) 关闭现在所有的IE窗口,并打开一个新窗口
Web.ExecWB(4,1) 保存网页
Web.ExecWB(6,1) 打印
Web.ExecWB(7,1) 打印预览
Web.ExecWB(8,1) 打印页面设置
Web.ExecWB(10,1) 查看页面属性
Web.ExecWB(15,1) 好像是撤销,有待确认
Web.ExecWB(17,1) 全选
Web.ExecWB(22,1) 刷新
Web.ExecWB(45,1) 关闭窗体无提示
<style media=print>
.Noprint{display:none;}<!--用本样式在打印时隐藏非打印项目-->
.PageNext{page-break-after: always;}<!--控制分页-->
</style>
<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
</object>
<center class="Noprint" >
<input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)>
<input type=button value=直接打印 onclick=document.all.WebBrowser.ExecWB(6,6)>
<input type=button value=页面设置 onclick=document.all.WebBrowser.ExecWB(8,1)>
</p>
<p> <input type=button value=打印预览 onclick=document.all.WebBrowser.ExecWB(7,1)>
</center>
//去掉打印时的页眉页脚
<script language="JavaScript">
var HKEY_Root,HKEY_Path,HKEY_Key;
HKEY_Root="HKEY_CURRENT_USER";
HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
//设置网页打印的页眉页脚为空
function PageSetup_Null()
{
try
{
var Wsh=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
HKEY_Key="footer";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
}
catch(e){}
}
//设置网页打印的页眉页脚为默认值
function PageSetup_Default()
{
try
{
var Wsh=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&w&b页码,&p/&P");
HKEY_Key="footer";
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"&u&b&d");
}
catch(e){}
}
</script>
<input type="button" value="清空页码" onclick=PageSetup_Null()>
<input type="button" value="恢复页码" onclick=PageSetup_Default()>