The print component that comes with IE, WebBrowser, simple solution for printing B/S projects, paging printing, print preview

Source: Internet
Author: User


When using the following statement, it is best to Try {} catch (e) {} to use IE with more than 5.5

The following content has been tested on IE6 7 and has a problem with the OK FF test.

Note: The following method calls are in IE6 and can be enclosed by brackets. IE7 cannot contain parentheses.

It is best not to enclose brackets for convenience.

  1. WebBrowser. ExecWB () Open
  2. WebBrowser. ExecWB () Close all existing IE Windows and open a new window
  3. WebBrowser. ExecWB () Save the webpage
  4. WebBrowser. ExecWB (6, 1) print
  5. WebBrowser. ExecWB (7,1) print preview
  6. WebBrowser. ExecWB (8, 1) print page settings
  7. WebBrowser. ExecWB (10, 1) view page properties
  8. WebBrowser. ExecWB () seems to be undo, to be confirmed
  9. Select All WebBrowser. ExecWB (17,1)
  10. WebBrowser. ExecWB (22, 1) Refresh
  11. WebBrowser. ExecWB () Close form no prompt

 

The last WebBrowser. ExecWB () can effectively solve the problem in IE7

WebBrowser. ExecWB () the window. close () method becomes invalid when print preview is executed and the result is returned to the original window.

  1. <Style media = "print" type = "text/css">
  2. . Noprint {display: none ;}
  3. . PageNext {page-break-after: always ;}
  4. </Style>
    Then, add "class =" Noprint "to the page element that you do not want to print. This will not appear in print or print preview.
    Add <div class = "PageNext> </div> to the page.


  1. <Div class = "PageNext">
  2. The first page of the printed content
  3. </Div>
  4. <Div class = "PageNext">
  5. The second page of the printed content
  6. </Div>
  7. <Div class = "pagenext">
  8. The third page of the printed content
  9. </Div>

For preview, run the following code:

This can be written when you open preview or print in a temporary window.

  1. Webbrowser. execwb (7,1 );
  2. Window. Opener = NULL;
  3. Window. Close ();

For A4 paper, 920 is used for horizontal and 640 is used for vertical la S.

  1. 1. Automatic line feed:
  2. <Style type = "text/CSS">
  3. . Autonewline
  4. {
  5. Word-break: Break-all;/* required */
  6. }
  7. </Style>
  8. <Table>
  9. <Tr>
  10. <TD class = "autonewline"> automatic newline automatic newline, automatic newline, automatic newline </TD>
  11. </Tr>
  12. </Table>
  13. 2. Do not wrap:
  14. <Style type = "text/CSS">
  15. . Nonewline
  16. {
  17. Word-break: Keep-all;/* required */
  18. }
  19. </Style>
  20. <Table>
  21. <Tr>
  22. <TD class = "nonewline"> no line breaks, no line breaks </TD>
  23. </Tr>
  24. </Table>
The settings of the header and footer are all written in vsscript by google. However, I have learned vb, so I can understand it. However, this does not affect your use. below is the code
  1. <Script language = "VBScript">
  2. Dim hkey_root, hkey_path, hkey_key
  3. Hkey_root = "HKEY_CURRENT_USER"
  4. Hkey_path = "/software/Microsoft/Internet Explorer/pagesetup"
  5. '// Set the page header and footer to be blank
  6. Function pagesetup_null ()
  7. On Error resume next
  8. Set regwsh = Createobject ("wscript. Shell ")
  9. Hkey_key = "/Header"
  10. Regwsh. regwrite hkey_root + hkey_path + hkey_key ,""
  11. Hkey_key = "/footer"
  12. RegWsh. RegWrite hkey_root + hkey_path + hkey_key ,""
  13. End function
  14. '// Set the page header and footer to the default value.
  15. Function pagesetup_default ()
  16. On error resume next
  17. Set RegWsh = CreateObject ("WScript. Shell ")
  18. Hkey_key = "/header"
  19. RegWsh. RegWrite hkey_root + hkey_path + hkey_key, "& w & B page number, & p/& P"
  20. Hkey_key = "/footer"
  21. RegWsh. RegWrite hkey_root + hkey_path + hkey_key, "& u & B & d"
  22. End function
  23. </Script>
Header and footer parameters usage window title & w
Webpage address (URL) & u
Short Date Format (specified by "region Settings" in "Control Panel") & d
Long Date Format (specified by "region Settings" in "Control Panel") & D
Current page number & p
Total number of pages & P
Right-aligned text (followed by & B) & B
Text Center (between & B) & B

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.