日期:2014-05-16 浏览次数:20503 次
function doPrint() {
var HKEY_Root,HKEY_Path,HKEY_Key;
HKEY_Root="HKEY_CURRENT_USER";
HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
try{
var Wsh=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
if(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key)!="" || !"".equals(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key))){
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"","REG_SZ");
}
}catch(e){}
try{
HKEY_Key="footer";
if(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key)!="" || !"".equals(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key))){
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"");
}
}catch(e){}
try{
HKEY_Key="margin_left";
if(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key)!="0" || !"0".equals(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key))){
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0"); //键值设定--左边边界
}
}catch(e){}
try{
HKEY_Key="margin_top";
if(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key)!="0" || !"0".equals(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key))){
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0"); //键值设定--上边边界
}
}catch(e){}
try{
HKEY_Key="margin_right";
if(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key)!="0" || !"0".equals(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key))){
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0"); //键值设定--右边边界
}
}catch(e){}
try{
HKEY_Key="margin_bottom";
if(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key)!="0" || !"0".equals(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key))){
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0"); //键值设定--下边边界
}
}catch(e){}
try{
HKEY_Key="Print_Background";
if(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key)!="no" || !"no".equals(Wsh.RegRead(HKEY_Root+HKEY_Path+HKEY_Key))){
Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"no"); //键值设定--背景色
}
}catch(e){}
try{
bdhtml=window.document.body.innerHTML;
sprnstr="<!--startprint-->";
eprnstr="<!--endprint-->";
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML=prnhtml;
window.print();
return true;
}catch(e){
var errorMsg = e.message+"\r"+"请设置:IE选项->安全->Internet->"+"ActiveX控件和插件"+"\r"+"对未标记为可安全执行脚本的ActiveX的控件初始化并执行脚本->允许/提示";
alert(errorMsg);
return false;
}
}