<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Print.aspx.cs" Inherits="Print" %>
<!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 runat="server">
<title>Untitled Page</title>
<script type="text/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 PrintPreview(){
pagesetup_null();
document.all.wb.execwb(7,1);
return true;
}
function printsetup()
{
// 打印页面设置
var wb = document.getElementById("wb");
wb.execwb(8, 1);
}
function printpreview()
{
// 打印页面预览
pagesetup_null();
var wb = document.getElementById("wb");
SetVisible("none");
wb.execwb(7, 1);
SetVisible("block");
}
function printit()
{
pagesetup_null();
SetVisible("none");
window.print();
//wb.execwb(6, 6)
SetVisible("block");
}
function SetVisible(display)
{
document.getElementById("trPrint").style.display = display;
}
-->
</script>
</head>
<body>
<form id="form1" runat="server">
<object id="wb" height="0" width="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" name="wb" ></object>
<div id="trPrint">
<input onclick="javascript:printit()" type="button" value="打印" name="btnPrint" id="btnPrint" />
<input onclick="javascript:printsetup();" type="button" value="打印页面设置" name="btnSetup" id="btnSetup" />
<input onclick="javascript:printpreview();" type="button" value="打印预览" name="btnPreview" id="btnPreview"/>
<input onclick="window.close()" type="button" value="关闭" />
</div>
</form>
</body>
</html>
分享到:
相关推荐
JS打印页面代码JS打印页面代码JS打印页面代码JS打印页面代码JS打印页面代码JS打印页面代码JS打印页面代码
asp打印代码 打印页面设置 打印预览
javascript打印网页中指定部分的内容
VC++获得和设置打印页码的范围示例 VC++获得和设置打印页码的范围示例,调用系统公共的打印接口程序,设置打印页面的页码范围,不多说了,有用的自己下载测试。
调用浏览器打印按钮,实现打印页面功能,可以实现二次开发
一个简单的c#打印源码,使用微软自带的打印,并进行相应的页面设置
C# 利用 WebBrower 来打印内容
主要介绍了js调用iframe实现打印页面内容的方法,需要的朋友可以参考下
js指定打印页面部分内容代码,可以指定网页上的文本段落进行局部打印。
通过前台代码用于打印页面带有指定的水印内容,用于防伪和表明出处。所给代码是简易版的HTML页面,包含2部分,主体内容和附加水印
javascript打印网页,ajax处理数据
IE浏览器中打印网页时网页版面太大或太宽打印不全.docx
VC 获得打印页面信息,主要是获得打印页面宽度、高度、物理页面宽度、高度、上、下、左、右页边距等信息。不想下载完整源码包的,可先看下面的核心代码段: //打印对话框 DWORD dwFlags = PD_ALLPAGES | PD_...
批量打印页面数据
用Javascript打印网页指定标签的内容
使用WebBrowser控件打印页面demo,通过修改demo中的几行代码就可以使用
通过 libpcap 抓包 分析http包 并打印网页标题
实例如下: <!DOCTYPE ...<... <head>...js print打印网页指定区域内容的简单实例</title> </head> <sc
一个很好用的打印网页控件 一个很好用的打印网页控件