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即可

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即可

关键字标签:

上一篇:ExtJavaScript根据条件设置表格某行背景色示例
下一篇:javascript中声明函数的方法及调用函数的返回值