<input type="button" onclick="javascript:printit()"></input>//打印整个html网页.
//打印局部html网页 extjs中的例子
bdhtml = window.document.body.innerHTML;
startprint = ("<div>");
endprint = ("</div>");
printhtml = bdhtml.substr(bdhtml.indexOf(startprint) );
printhtml = printhtml.substr(0, printhtml.indexOf(endprint));
window.document.write(‘<html>‘);
window.document.write(‘<head>‘);
window.document.write(‘<title>打印列表</title>‘);
window.document.write(‘</head>‘);
window.document.write(‘<body><from>‘);
window.document.write(printhtml);
window.document.write(‘<from></body>‘);
window.document.write(‘</html>‘);
window.print();
window.location.reload();//加载页面
时间: 2024-10-07 19:39:45