<script type="text/javascript">
function preview()
{
var bdhtml=window.document.body.innerHTML;
var sprnstr="<!--startprint-->";
var eprnstr="<!--endprint-->";
var prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
window.document.body.innerHTML=prnhtml;
window.print();
location.reload();
}
</script>
<input id="btnPrint" type="button" value="打 印" onclick="preview();" class="button2" />
<!--startprint-->
这里填写 你要打印的代码
<!--endprint-->