首页  >  文章  >  web前端  >  jQuery打印图片pdf、txt示例代码_jquery

jQuery打印图片pdf、txt示例代码_jquery

WBOY
WBOY原创
2016-05-16 16:41:241846浏览

html加如下代码

<div style="display:none"> 
<div id="to_print"></div> 
<input type="button" id="print_button" value="Print" onclick="document.getElementById('FILEtoPrint').focus(); document.getElementById('FILEtoPrint').contentWindow.print();" /> 
</div> 

<script> 
function printSome(path){ //传入文件路径 
$("#to_print").html('<iframe src='+path+' id="FILEtoPrint"></iframe>'); 
setTimeout(function(){$("#print_button").click();}, 500); 
} 
</script>

web界面添加按钮调用js即可

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn