首页 > Web开发 > 详细

打印选中的网页

时间:2020-05-26 14:15:27      阅读:30      评论:0      收藏:0      [点我收藏+]
 //把需要打印的代码,替换掉body中的内容,执行window.print()方法
document.getElementsByTagName("body")[0].style.overflow=‘auto‘ // this.$print(this.$refs.print) var arr=document.getElementsByClassName(‘v-transfer-dom‘) arr.forEach(function(item){ item.style.display=‘none‘ }) var tables=document.getElementsByTagName(‘table‘); tables.forEach(function(item){ item.style.width=‘100%‘ item.setAttribute(‘width‘,‘100%‘); }) var td=document.getElementsByTagName(‘td‘); td.forEach(function(item){ item.style.width=‘auto‘ item.setAttribute(‘width‘,‘auto‘); }) setTimeout(function(){ document.getElementById(‘app1‘).innerHTML="" document.getElementById(‘app1‘).appendChild((document.getElementById(‘print‘).cloneNode(true))) window.print(); window.location.reload(); })

 

打印选中的网页

原文:https://www.cnblogs.com/liuhao-web/p/12858090.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!