Javascript: window. Print () print [reprint]

Source: Internet
Author: User

Javascript: window. Print ()
Print

1. Javascript Printing
<Input id = "btnprint" type = "button"
Value = "button" onclick = "javascript: window. Print ();"
Style = "color: # 00f;
Font-weight: bold; text-Decoration: none; cursor: pointer! Important;
Cursor: Hand "/>
You can use style control to print the print. The style is as follows:
<Style type = "text/CSS" Media = print>
. Noprint {display: None}
</Style>
Then you can use the style:
<P class = "noprint"> No printing required </P>

To print a part of a Web page, you just need to mark this Part
<! -- Startprint --> <! --- Endprint -->.
========================================================== ==================================
2. Print IE
<Script language = "JavaScript">

// Print page settings
Function printsetup () {wb.exe CWB (8, 1 );}
// Print the Page Preview
Function printpreview () {wb.exe CWB (7,1 );}
Function printit () {If (confirm ('Are you sure you want to print? ')){
Wb.exe CWB (6, 6 )}}
</SCRIPT>
</Head>
<Body>
<Object classid = "CLSID: 8856f961_340a_11d0_a96b_00c04fd705a2"

<LINK rel = Alternate media = print
Href = "printversion.doc"> Height = 0 id = WB name = WB
Width = 0> </Object>
<Input type = button name = button_print
Value = "print"
Onclick = "javascript: printit ()">
<Input type = button name = button_setup
Value = "print page settings"
Onclick = "javascript: printsetup ();">
<Input type = button name = button_show
Value = "print preview" onclick = "javascript: printpreview ();">
<Input type = button name = button_fh
Value = "close"
Onclick = "javascript: window. Close ();">

------------------------------------------------
There are other usage examples of this component:
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 (7,1) print and preview
Web. execwb (8, 1) Printing page settings
Web. execwb () view page properties
Web. execwb () seems to be undo, to be confirmed
Select all web. execwb ()
Web. execwb (22, 1) Refresh
Web. execwb () Close form no prompt

 

 

 

<% @ Page Language = "C #" Autoeventwireup = "true" Codefile = "default. aspx. cs" Inherits = "dept_default" %>

 

<! Doctype Html Public "-// W3C // dtd xhtml 1.0 transitional // en" Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>

<Html Xmlns = "http://www.w3.org/1999/xhtml">

<Head Runat = "server">

<Title> </title>

<Script Type = "text/JavaScript">

FunctionPrintpage ()

{


Document. getelementbyid (
"Noprint"). Style. Display ="None";//Print the entire page with the title. Hide the page labels that do not need to be printed before calling the print method. No title will print the title

Print ();

 

}

FunctionPrintsetup ()

{

Try

{


Document. All. webbrowser. execwb (8, 1 );

}

Catch(E)

{

// Ymprompt. errorinfo ({Title: sys_name,
Message: 'activex is required for page settings. Allow ActiveX to be used on this site '});

}

Printpage ();

}

</SCRIPT>

 

</Head>

<Body>

<Object Id = "webbrowser" Classid = "CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2" Height = "0"

Width = "0" Viewastext>

</Object>

<Form Id = "form1" Runat = "server">

<Font Color = "red">Print and print<Br />Drib</Font>Dfdsfdsfds

<Div>

<Input Type = "button" Value = "print" Id = "noprint" Class = "btnnm" Onmouseover = "This. classname = 'btnon '"

Onmouseout = "This. classname = 'btnnm '" Onclick = "printsetup ();" />

</Div>

</Form>

</Body>

</Html>

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.