Javascript page printing and javascript Printing

Source: Internet
Author: User

Javascript page printing and javascript Printing

The WebBrowser component isIEThe built-in browser control, when used, first declare the WebBrowser component with the <object>... </object> tag under the <body> label. The Code is as follows:

<object id="WebBrowser1"width="0" height="0" classid = "CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">     </object>

Print the page mainly through the execWB () method of the WebBrowser component.

Syntax: WebBrowser.exe cWB (n1_id, nCmdOpt)

NCmdID: required. Command for executing the operation function

NCmdOpt: required. Execute the corresponding option, usually 1.

Common parameters are as follows:

WebBrowser. ExecWB () Open

Web. ExecWB () Close all existing IE Windows and open a new window

Web. ExecWB () save Web Page

Web. ExecWB (6, 1) Printing

Web. ExecWB (6, 6) Direct Printing

Web. ExecWB (7,1) print and preview

Web. ExecWB (8, 1) Printing page settings

Web. ExecWB () view page properties

Select all Web. ExecWB ()

Web. ExecWB (22, 1) Refresh

Web. ExecWB () Close form no prompt

Paging Printing

CSS has a Media attribute that allows you to set the print and display formats separately.

For example, <style media = "print" type = "text/css">... </Style> the format in the middle will only take effect during printing and will not affect the display interface.

So you can set

<style media="print" type="text/css">.Noprint {display:none;}.PageNext {page-break-after:always;}</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 <divclass = "PageNext"> </div> to the page.


Print content in the specified iframe framework

The framework content on the print page is that you first need to get the focus for the Framework, which can be implemented using the built-in object parent. parent refers to the parent window that contains the current split window.

parent.printFrame.focus();window.print();

PrintFrame is the name of the framework to be printed.

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.