Copy codeThe Code is as follows:
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> javascript printing page </title>
<Script type = "text/javascript"> <! --
Function fPrint (){
// Hide the content that does not need to be printed.
Document. getElementById ("divOperate"). style. display = "none ";
Document. all. WebBrowser. ExecWB (7,1 );
Document. getElementById ("divOperate"). style. display = "block ";
}
// --> </Script>
</Head>
<Body>
<Div id = "divOperate">
<A href = "javascript: void (0);" href = "javascript: void (0);" onclick = "fPrint ();"> Print </a>
<Object id = "WebBrowser" width = "10" height = "10" classid = "CLSID: 8856F961-340A-11D0-A96B-00C04FD705A2"> </object>
</Div>
<Div id = "divPrint">
<Div> set the title </div>
<Table border = "1">
<Tr>
<Td> the content to be printed </td>
<Td> hello </td>
<Td> hello </td>
</Tr>
<Tr>
<Td> hello </td>
<Td> hello </td>
<Td> hello </td>
</Tr>
</Table>
</Div>
</Body>
</Html>