Home > Article > Web Front-end > Javascript implements window.print() to remove headers and footers_javascript skills
Remove the header and footer when printing. Just add the following code before printing: var HKEY_Root,HKEY_Path,HKEY_Key;
HKEY_Root="HKEY_CURRENT_USER";
HKEY_Path="\Software\Microsoft\Internet Explorer\PageSetup\";
var head,foot,top,bottom,left,right;
var Wsh=new ActiveXObject("WScript.Shell");
HKEY_Key="header";
//Set the header (empty) Fill in the header according to what you want to set
Wsh.RegWrite(HKEY_Root HKEY_Path HKEY_Key,"");
HKEY_Key="footer";
//Set the footer (empty) Fill in according to what you want to set
Wsh.RegWrite(HKEY_Root HKEY_Path HKEY_Key,"");
HKEY_Key="margin_bottom";
//Set the lower page margin (0) and fill it in according to what you want to set
Wsh.RegWrite(HKEY_Root HKEY_Path HKEY_Key,"0");
HKEY_Key="margin_left";
//Set the left margin (0) and fill it in according to what you want to set
Wsh.RegWrite(HKEY_Root HKEY_Path HKEY_Key,"1");
HKEY_Key="margin_right";
//Set the right margin (0)
Wsh.RegWrite(HKEY_Root HKEY_Path HKEY_Key,"0");
HKEY_Key="margin_top";
//Set the top margin (8)
Wsh.RegWrite(HKEY_Root HKEY_Path HKEY_Key,"1");