<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript">
//获取参数
var dada = dialogArguments;
function loaddatas(){
//如果有样式
if(dada[1]!=null){
addStyle( dada[1]);
}
//数据加载
var da1 = dada[0];
var pf = document.all.item('printfield');
pf.insertAdjacentHTML('beforeEnd',da1);
return;
}
//把需要的样式写入到打印界面
function addStyle(url){
var link=document.createElement("link");
link.rel="stylesheet";
link.type="text/css";
link.href=url;
document.getElementsByTagName("head")[0].appendChild(link);
}
//开始打印
function startprint(){
document.all.item("startbutt").style.display='none';
window.print();
document.all.item("startbutt").style.display='';
return;
}
//通过修改注册表设置页眉页脚
var HKEY_RootPath="HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
//清空页眉和页脚
function PageSetup_del(){
try{
var WSc=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
WSc.RegWrite(HKEY_RootPath+HKEY_Key,"");
HKEY_Key="footer";
WSc.RegWrite(HKEY_RootPath+HKEY_Key,"");
}catch(e){}
}
//恢复页眉和页脚
function PageSetup_set(){
try{
var WSc=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
WSc.RegWrite(HKEY_RootPath+HKEY_Key,"&w&b页码,&p/&P");
HKEY_Key="footer";
WSc.RegWrite(HKEY_RootPath+HKEY_Key,"&u&b&d");
}catch(e){}
}
</script>
</head>
<body leftMargin=0 topMargin=0 marginheight="0" marginwidth="0" onload="javascript:loaddatas();" style="word-break:break-all">
<table align="center">
<tr>
<td align="center" id="printfield"></td>
</tr>
</table>
<!-- 按钮区域不需打印 -->
<table width="100%" id="startbutt">
<tr>
<td align=center>
<input type="button" value="打印" onclick="javascript:startprint();">
<input type="button" value="清空页眉页脚" onclick="PageSetup_del()">
<input type="button" value="恢复页眉页脚" onclick="PageSetup_set()">
</td>
</tr>
</table>
</body>
</html>
评论1
最新资源