28,406
社区成员
发帖
与我相关
我的任务
分享
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT>
<div id=prn>
<center>
<input type="button" name="pr" value=" 打印预览 " onclick='javascript:prn();'> <a href='' onclick='javascript:window.close();'>>>关闭窗口<<</a>
</center>
</div>
<script language='javascript'>
var IsIE=true;
if(!document.all){IsIE=false;}//简单判断一下是不是IE
function pSetup(){ // 打印页面设置
try{wb.execwb(8,1);prn.style.display="none";}
catch(e){alert(e);}
}
function pPreview(){ // 打印页面预览
try{wb.ExecWB(7,1);prn.style.display="none";}
catch(e){alert(e);}
}
function prn(){
//alert(IsIE)
if(IsIE){
pagesetup_null(); //处理页眉页脚
var e=document.getElementById("prn")//把不需要的地方隐藏起来,如果需要隐藏的控件多于一个,用相同的name明明,用getElementsByName获取控件数组,然后循环下面这句.......
e.style.display="none";
wb.execwb(7,1);
window.opener=null;window.open('','_self');window.close;
}
else{window.print();}
}
function pagesetup_null(){//设置网页打印的页眉页脚为空
var hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"
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(){//设置网页打印的页眉页脚为默认值
var hkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\"
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>