First, describe the problem:
By default, the printed content in the IE Print dialog box contains the header and footer.
View the page settings of IE, such as the header and footer in the picture on the right.
The following describes the meaning of & W & bpage & P of & P, & U & B & D.
& W-window title
& U-page address
& D-short date format, for example, 10/12/2006
& D-long date format, such as tursday, October 12,200 6
& T-12-hour time
& T-24-hour time
& P-page number
& P-total page number
&-That is &
& B-align the text before the symbol to the right
& B-align the text in the text drama before the first symbol, and align the text in the right end before the second symbol
Of course, you can manually delete the header and footer. If you just don't want to modify it yourself, you can force the modification using the following script:CopyCodeThe Code is as follows: var hkey_root, hkey_path, hkey_key
Hkey_root = "HKEY_CURRENT_USER"
Hkey_path = "\ Software \ Microsoft \ Internet Explorer \ pagesetup \\"
// Set the page header and footer to be empty.
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 ){}
}
This is a bit embarrassing. It is used to modify the registry. Therefore, a dialog box is usually displayed.
If you click "yes", the header and footer are missing as you wish.
Next, what if we need to restore it?
CodeCopy codeThe Code is as follows: // set the page header and footer to the default value.
Function pagesetup_default (){
Try {
VaR regwsh = new activexobject ("wscript. Shell ")
Hkey_key = "Header"
Regwsh. regwrite (hkey_root + hkey_path + hkey_key, "& W & B page number, & P/& P ")
Hkey_key = "footer"
Regwsh. regwrite (hkey_root + hkey_path + hkey_key, "& U & B & D ")
} Catch (e ){}
}
Wscript. shell (Windows Script Host Runtime Library) is an object corresponding to c: \ windows \ system32 \ wshom. OCX, wscript. shell is a component used by the server system. Shell is the meaning of "shell". This object can perform common operations on the operating system shell, such as runningProgram, Read and write the registry, environment variables, and so on.
For more wscript applications, see http://www.jb51.net/article/21296.htm