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>