改注册表:
<HTML><HEAD>
<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){}
}
</script>
</HEAD><BODY><br/><br/><br/><br/><br/><br/><p align=center>
<input type="button" value="清空页码" onclick=pagesetup_null()>
<input type="button" value="恢复页码" onclick=pagesetup_default()><br>
</p></BODY></HTML>
<HTML><HEAD>
<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){}
}
</script>
</HEAD><BODY><br/><br/><br/><br/><br/><br/><p align=center>
<input type="button" value="清空页码" onclick=pagesetup_null()>
<input type="button" value="恢复页码" onclick=pagesetup_default()><br>
</p></BODY></HTML>
解决方案 »
- 救助高手!onclick事件!
- Javascript打开新窗口问题
- 请问什么是本地对象
- 如何按指定获取数组中的值
- JavaScript 变量问题
- 用JavaScript判断页面是否第一次加载
- label国际化如何取变量的值
- javascript中 window.变量名 是全局对象吗?
- 选中一个选项后相关内容显示出来,选中另一选项,相关内容隐藏起来(单选框)。如何实现
- 急!如何实现javascript和数据库的连接高手帮忙!
- 【难么?】如何判断网页的元素全部加载完毕??
- 把一个页面自动另存为一个指定名称html页面,怎么样实现,俺知道document.execCommand('SaveAs')命令可以实现另存,但他会弹出一个保存对
具体请查看 WINDOWS UPDATE 的网站
他有两个打印 一个是打印当前页就是普通的打印网页
一个是打印全部 做法是把所有数据取出来放到一个TABLE里 然后把TABLE放到一个隐藏的框架
可以借鉴他的好多函数的!
http://blog.csdn.net/qmei/archive/2005/04/11/342968.aspx
不需要打印机驱动,嘿嘿
<html>
<head></head>
<body>
<script language=javascript>
var MyFileObject = new ActiveXObject("Scripting.FileSystemObject");
var MytextFile = new ActiveXObject("Scripting.FileSystemObject");
MytextFile = MyFileObject.CreateTextFile("Lpt1");
var PDStr = "test";
MytextFile.WriteLine(PDStr);
MytextFile.Close();
</script>
</body>
</html>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="images/style_index.css" type=text/css rel=stylesheet>
<style type="text/css">
<!--
.tab {
background-color: #f7f7f7;
border: 1px solid #999999;
font-size: 12px;
color: #333333;
BORDER-LEFT-COLOR: #000000;
BORDER-BOTTOM-COLOR: #000000;
BORDER-TOP-COLOR: #000000;
BORDER-COLLAPSE: collapse;
BORDER-RIGHT-COLOR: #000000
}
-->
</style>
<SCRIPT language=javascript>
function printpr()
{
document.all("qingkongyema").click();
document.all("dayinDiv").style.display="none";
var OLECMDID = 7;
var PROMPT = 1;
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(OLECMDID, PROMPT);
WebBrowser1.outerHTML = "";
document.all("dayinDiv").style.display="";
}function printTure()
{
document.all('qingkongyema').click();
document.all("dayinDiv").style.display="none";
window.print();
document.all("dayinDiv").style.display="";
}
function doPage()
{
layLoading.style.display = "none";
}</SCRIPT><script language="VBScript">
dim hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\Software\Microsoft\Internet Explorer\PageSetup"
'//设置网页打印的页眉页脚为空
function pagesetup_null()
on error resume next
Set RegWsh = CreateObject("WScript.Shell")
hkey_key="\header"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
hkey_key="\footer"
RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""
end function
'//设置网页打印的页眉页脚为默认值
function pagesetup_default()
on error resume next
Set RegWsh = CreateObject("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"
end function
</script></HEAD>
<BODY background="images/background_01.gif" leftMargin=0
topMargin=0 rightMargin=0 bottomMargin=0 style="BACKGROUND-POSITION: center 50%">这就是你要的东西!!!
<DIV align="center" id="dayinDiv" name="dayinDiv"><input type="button" class="tab" value="打印" onclick="printTure();">
<input type="button" class="tab" value="打印预览" onclick="printpr();">
<input type="hidden" name="qingkongyema" id="qingkongyema" class="tab" value="清空页码" onclick="pagesetup_null()">
<input type="hidden" class="tab" value="恢复页码" onclick="pagesetup_default()">
</DIV>
</BODY></HTML><script language="javascript">
var jtqkxx,pxjl,zyxx
jtqkxx=<%=jtqkxx%>;
pxjl=<%=pxjl%>;
zyxx=<%=zyxx%>;if(jtqkxx=="1")
{
document.all("jtqkxx").style.display="";
}if(pxjl=="1")
{
document.all("pxjl").style.display="";
}
if(zyxx=="1")
{
document.all("zyxx").style.display="";
}
</script>
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()>