按钮调用Print()方法直接打印body中的内容。
?
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 Print() {
?if(confirm("确定要打印?")) {
?pagesetup_null();
?var headstr = "<html><head><title></title></head><body>";
?var footstr = "</body>";
?var oldstr = document.body.innerHTML;
?var noPrint = document.getElementById("noprint");
?noPrint.style.display='none';
?$(".main_table").css("width","640px");? //设置表格的宽度
?var newstr = document.body.innerHTML;
?document.body.innerHTML = headstr+newstr+footstr;??
?window.print();
?document.body.innerHTML = oldstr;
?pagesetup_default();
?}
}