1. Foreground JavaScript
<script language= "javascript" type= "Text/javascript" >
function Printdiv () {
bdhtml = Window.document.body.innerHTML;
Sprnstr = "<!--startprint-->";//Start printing marks
Eprnstr = "<!--endprint-->";//End Print Mark
prnhtml = Bdhtml.substr (Bdhtml.indexof (SPRNSTR) + 17);
prnhtml = prnhtml.substring (0, Prnhtml.indexof (eprnstr));
Window.document.body.innerHTML = prnhtml;
Window.print ();
Window.document.body.innerHTML = bdhtml;
CloseWindow ();
}
function CloseWindow () {
SetTimeout ("Window.opener=null;window.open (", ' _self '); Window.close (); ", 2000); 2 seconds after printing and then jump
}
</script>
2. Use
<!--startprint-->//Start printing node in foreground tag
<!--endprint-->//End print Node
3. Background Call code
This. Page.ClientScript.RegisterStartupScript (this. Page.gettype (), "", "<script>printdiv (); Window.close ();</script>", false);/There are ScriptManager controls