js打印代码: 

var bdhtml=document.getElementById("content1").innerHTML;

window.document.body.innerHTML=bdhtml;

window.print();



<!-- 打印内容在这里 -->

<div id="printWnd" style="display:none;">

<label>姓名:</label><label id="p_userName"></label><br>

<label>身份证号:</label><label id="p_idCard"></label><br>

<label>科目名称:</label><label id="p_subjectName"></label><br>

<label>电话号码:</label><label id="p_telPhone"></label><br><br>

<label>补考费金额:</label><label id="p_extraFee"></label><br>

<label>补考费原因:</label><label id="p_remark"></label><br>

</div>


var text = $("#printWnd")[0].innerHTML;

printView(text); //打印预览


//打印预览

function printView(obj){

var oWin=window.open("","_blank");

var strPrint="<h4 style=’font-size:18px; text-align:center;’>补考费-打印预览</h4>\n";



strPrint=strPrint +"<script type=\"text/javascript\">\n";


strPrint=strPrint + "function printWin()\n";

strPrint=strPrint + "{";

strPrint=strPrint + "var bdhtml=document.getElementById(\"content1\").innerHTML;\n";

strPrint=strPrint + "window.document.body.innerHTML=bdhtml; \n";

strPrint=strPrint + "window.print(); \n";

strPrint=strPrint + "}";

strPrint=strPrint + "<\/script>\n";





strPrint=strPrint + "<div id=\"content1\" >\n";

strPrint=strPrint + obj + "\n";

strPrint=strPrint + "</div>\n";



strPrint=strPrint + "<hr size='1'/>\n";

strPrint=strPrint + "<div style='text-align:center'><button οnclick='printWin();' style='padding-left:4px;padding-right:4px;'>打 印</button><button οnclick='window.close();' style='padding-left:4px;padding-right:4px;'>关 闭</button></div>\n";



oWin.document.write(strPrint);

oWin.focus();



oWin.document.close();

}