JS print related content

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.