//打印print:function(){//获取打印的页面内容let subOutputRankPrint = document.getElementById('print-div');let newContent = subOutputRankPrint.innerHTML;let oldContent = document.body.innerHTML;document.body.innerHTML = newContent;//页面打印缩放比例设置document.getElementsByTagName('body')[0].style.zoom=0.92;//检测是否是IE 如果是ie进行页眉页脚if(!!window.ActiveXObject || "ActiveXObject" in window){var hkey_root, hkey_path, hkey_key;hkey_path = "HKEY_CURRENT_USER\\Software\\Microsoft\\Internet"+ "Explorer\\PageSetup\\";try {var RegWsh = new ActiveXObject("WScript.Shell");RegWsh.RegWrite(hkey_path + "header", "");RegWsh.RegWrite(hkey_path + "footer", "");} catch (e) {}}window.print();window.location.reload();//将原有页面还原到页面document.body.innerHTML = oldContent;return false;},}
//chrome下进行页眉页脚消除 使用css 样式进行消除
// 测试ie11,chrome,firefox,edge 可消除页眉页脚
@media print{
@page{
margin:0;
//控制是使用a4还是使用其它纸张规格
size:auto;
}
}