Use the WebBrowser Control
1. WebBrowser control (partial printing can be achieved through Style setting)
<Object ID = 'webbrowser 'width = 0 HEIGHT = 0 CLASSID = 'clsid: 8856F961-340A-11D0-A96B-00C04FD705A2 '> </object>
2. WebBrowder Control Method
1. Print
WebBrowser1.ExecWB (6, 1 );
2. Print settings
WebBrowser1.ExecWB (8, 1 );
3. Print and preview
WebBrowser1.ExecWB (7,1 );
3. Print the header and footer settings
Var hkey_root, hkey_path, hkey_key
Hkey_root = "HKEY_CURRENT_USER"
Hkey_path = "\ Software \ Microsoft \ Internet Explorer \ PageSetup \\"
1. Clear the header and footer
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 ){}
2. Set the header and footer www.2cto.com
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 ){}
4. Page Printing
Since printing prints the entire page, if you only need to print the data table, we will hide the part that we do not want to print.
1,
// Hide all layers other than the specified id
Function setdivhidden (id ){
Var divs = document. getElementsByTagName ("DIV ");
For (var I = 0; I <divs. length; I ++)
{
If (divs. item (I). id! = Id)
Divs. item (I). style. display = "none ";
}
}
2,
// Print page settings
Function printsetup (){
WebBrowser.exe cwb (8, 1 );
}
3. // print the Page Preview
Function printpreview (){
WebBrowser.exe cwb (7,1 );
}
4. Print
Function printit (){
If (confirm ('Are you sure you want to print? '))
WebBrowser.exe cwb (6, 1)
}
5. HTML page elements
<OBJECT classid = "CLSID: 8856F961-340A-11D0-A96B-00C04FD705A2" height = 0 id = wb name = wb width = 0> </OBJECT>
<Input type = button name = button_print value = "print" class = "noprint" onclick = "javascript: printit ()">
<Input type = button name = button_setup value = "print page settings" class = "noprint" onclick = "javascript: printsetup ();">
<Input type = button name = button_show value = "print preview" class = "noprint" onclick = "javascript: printpreview ();">
From Core_Star's column