JS window.print() 调用前后监听


var beforePrint = function(){
    console.log('beforePrint')
  //页面打印缩放比例设置
document.getElementsByTagName('body')[0].style.zoom=0.92; };
var afterPrint = function(){ console.log('afterPrint')
//页面打印结束或取消时还原
document.getElementsByTagName('body')[0].style.zoom=1; }
if(window.matchMedia){ var mediaQueryList = window.matchMedia('print'); mediaQueryList.addListener(function(mql){ if(mql.matches){ beforePrint() }else{ afterPrint(); } }); }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM