列印该事件:window.print()
1.白眉林列印(产业布局列印):
function printCnt(){
//1.以获取现阶段页的html标识符
var body = window.document.body.innerHTML;
//2.要列印的部份(#print里头的文本是要列印的文本)
window.document.body.innerHTML =document.getElementById("print").innerHTML;
window.print();
window.document.body.innerHTML = body;
//再次写入现阶段文件格式:
location.reload();
}
特别注意:location.reload();加有,因可化解JS window.print()第三次点选该事件失灵难题
2.大批量列印
特别注意点:
(1).掌控页面的巨集:page-break-after:always
特别注意:防止在表单、自由浮动原素、暗含前面板的块原素中采用巨集特性
(2).给每一巨集的文本加有两个度,防止Faster
诊断书1
诊断书2
(3).假如采用window.open(“showPrint.html”,”print”); 列印自动更新页面不然
//假如是本地测试,需要先新建Print.html,假如是在域中采用,则不需要
// res 是后端返回的需要列印的xxx.html页面
var pwin=window.open(res,"print");
pwin.document.write(res);
pwin.document.close();//这个是必须的
特别注意:pwin.document.close(); 可以关闭showPrint.html的页面,使其第三次列印的时候不会跳转到showPrint.html