Example of js control paging printing and printing Paging

Source: Internet
Author: User

Copy codeThe Code is as follows:
<% @ Page language = "java" contentType = "text/html; charset = UTF-8"
PageEncoding = "UTF-8" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE> javascript printing-print page settings-print preview Code </TITLE>
<META http-equiv = Content-Type content = "text/html; charset = gb2312"/>
<Style media = print>
. Noprint {display: none ;}
. PageNext {page-break-after: always ;}
</Style>
<SCRIPT language = javascript>
Function printsetup (){
// Print page settings
Wb.exe cwb (8, 1 );
}
Function printpreview (){
// Print the Page Preview
Wb.exe cwb (7,1 );
}
Function printit ()
{
If (confirm ('Are you sure you want to print? ')){
Wb.exe cwb (6, 6)
}
}
</SCRIPT>

</HEAD>
<BODY>

<DIV align = center>
<OBJECT id = wb height = 0 width = 0
Classid = CLSID: 8856F961-340A-11D0-A96B-00C04FD705A2 name = wb> </OBJECT>
<INPUT onclick = javascript: printit () type = button value = Print name = button_print/>
<INPUT onclick = javascript: printsetup (); type = button value = print page setting name = button_setup/>
<INPUT onclick = javascript: printpreview (); type = button value = print preview name = button_show/>
</DIV>
111 </br>
111 </br>
111 </br>
<Div class = "PageNext"> </div>
222 </br>
222 </br>
222 </br>
<Div class = "PageNext"> </div>
333 </br>
333 </br>
333 </br>
<Div class = "PageNext"> </div>
444 </br>
444 </br>
444 </br>
<Div class = "PageNext"> </div>
555 </br>
555 </br>
555 </br>
</BODY>
</HTML>

Copy codeThe Code is as follows:
<Html>
<Title> JS paging batch printing solution (IE only) </title>
<Script language = "javascript">
Function printWithAlert (){
Document. all. WebBrowser. ExecWB (6, 1 );
}
Function printWithoutAlert (){
Document. all. WebBrowser. ExecWB (6, 6 );
}
Function printSetup (){
Document. all. WebBrowser. ExecWB (8, 1 );
}
Function printPrieview (){
Document. all. WebBrowser. ExecWB (7,1 );
}
Function printImmediately (){
Document. all. WebBrowser. ExecWB (6, 6 );
Window. close ();
}
</Script>
<OBJECT id = WebBrowser classid = CLSID: 8856F961-340A-11D0-A96B-00C04FD705A2 style = "display: none">
</OBJECT>
</Noscript>
<Style media = print>
. Noprint {display: none;}. PageNext {page-break-after: always ;}
</Style>
<Table align = "center" class = NOPRINT>
<Tr>
<Td align = "center"> <BUTTON title = print onclick = printWithAlert ()> Print </BUTTON>
<BUTTON title = print onclick = printWithoutAlert ()> Print directly </BUTTON>
<Input type = button value = "Print Settings" onClick = "printSetup ()">
<Button onclick = 'printprieview () 'title = 'print preview...'> print preview </button> </td>
</Tr>
</Table>
<Div class = NOPRINT> The following is the print area: <br>
</Div>
<Hr size = 1 noshadow color = black class = NOPRINT>
<Table class = "PageNext">
<Tr>
<Td colspan = 2>
Content on the first page
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
</Td>
</Tr>
</Table>
<Hr size = 1 noshadow color = black class = NOPRINT>
<Div class = "PageNext">
Page 2
11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
</Div>
<Hr size = 1 noshadow color = black class = NOPRINT>
Page 3
</Html>

Related Article

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.