标签:func title attr 标签 通过 UNC fun cin window
1、在jsp中与table 标签 同层次添加iframe标签
<iframe id=‘frmPrint‘ width=‘0‘ height=‘0‘ frameborder=‘0‘></iframe> <table border="1" cellpadding="0" cellspacing="0" class="dateLisTable"> <thead style="background-color: #ebf5fc;"> </thead> <tbody id="dataBody"> </tbody> </table>
2、js中将表格数据写入到弹出框中
//打印功能 document.getElementById("frmPrint").contentWindow.document.body.innerText = ""; //iframe清空后在复制防止多次写入重复 $(".dsdaochu01").attr("style","display:none;"); //隐藏打印导出按钮 var initData = document.getElementsByClassName("page")[0].innerHTML var printData = document.getElementById("biao").innerHTML;// 获得 var printWindow=window.frames[‘frmPrint‘]; printWindow.document.write(printData);//内容写到iframe中去 $(".dsdaochu01").attr("style","display:true;"); //document.getElementsByClassName(".dsdaochu01").style.display = "block"; // 显示 layer.open({ type : 1, title: false, fix : true, shadeClose : true, area : [ ‘100%‘, ‘100%‘ ], closeBtn : 0, content :‘<div >‘ + printData + ‘</div>‘, btn : [‘打印‘,‘关闭‘], yes : function(index) { printWindow.focus(); window.print(); // 开始打印 }, success : function(layero) { $(‘.layui-layer-btn‘).position(‘relative‘); $(‘.layui-layer-btn‘) } });
3、打印不全问题
style="font-size:8px;height:100%;width:100%" 修饰表格
<table border="1" cellpadding="0" cellspacing="0" class="dateLisTable" style="font-size:10px;width:100%" >
</table>
通过宽度高度,字体大小调整
标签:func title attr 标签 通过 UNC fun cin window
原文地址:https://www.cnblogs.com/ssbydk/p/9541351.html