Re: http://www.nethai.net/ShowArticle.asp? ArticleID = 311
Java printing has many introductions. Currently, plain text printing can be implemented, including both Java applications and the applet, and the printing control can basically meet the requirements. this part cannot be detailed at once.
Many dishes, dishes, and vegetables are birds that cannot be used. They are printed in IE, not JSP or Java, I suggest these comrades not to learn programming, but to understand the basic things.
For printing in IE, JavaScript can only print pages. For example, \ r
<HTML>
<A href = javascript: Print ()> Print </a>
<Table>
111111111
</Table>
222222222
In this way, all content is printed. What if any table or element on the page is printed?
To print any element, we need to locate it first, that is, which of the following tables do we need to type?
Of course, you only need to give it a name or ID. For example, \ r
<Table id = A1>
<Tr> <TD> 1111 </TD> <tr>
</Table>
<Table id = A2>
<Tr> <TD> 2222 </TD> <tr>
</Table>
Now we need to print A1 content, including
<Table id = A1>
<Tr> <TD> 1111 </TD> <tr>
</Table>
If you get these values?
A1.innerhtml cannot include <Table id = A1> itself. your Alert (a1.innerhtml) will be <tbody> <tr> <TD> 11111 </TD> </tr> </tbody>
This is certainly not true. Then we need to get its content from outside it. a1.parentelement. innerhtml, its parentelement is body, and the body's innerhtml is not what we want, so we need
Add a package, such as \ r
<Span>
<Div> yes, it only sets
<Table id = A1>
<Tr> <TD> 1111 </TD> <tr>
</Table>
<Table id = A1>
<Tr> <TD> 1111 </TD> <tr>
</Table> the parentelement. innerhtml is itself. For example, \ r.
<Span>
<Table id = A1>
<Tr> <TD> 1111 </TD> <tr>
</Table>
</Span>
<Span>
<Table id = A2>
<Tr> <TD> 2222 </TD> <tr>
</Table>
</Span>
Alert (a1.parnetelement. innerhtml)
See
<Table id = A1>
<Tr> <TD> 1111 </TD> <tr>
</Table>
It's exactly what we want to print. What if we print it out?
Fp = Window. Open ("", aname, "Top = 2000000 ,.....")
Fp.doc ument. Write (a1.parnetelement. innerhtml );
Fp.doc ument. Write ("<" + "script> Print (); </" + "script> ");
FP. Location. Reload ();
FP. Close ();
That is to say, write the content to be printed to another page. This page only contains the content you want to print. Javascript still prints the full page, but it is exactly what you want. the printing in the new area is not executed when it is written. You need to reload the page. shut it down after the fight. That's it. Class.