script language=javascript var printIt = function() { if (confirm(‘确定打印吗?‘ )) { bindData(); var mWindow = window; window.document.body.innerHTML = document.getElementById("form" ).innerHTML; //字体调整 $( "input,label,se
<script language=javascript> var printIt = function() { if (confirm(‘确定打印吗?‘)) { bindData(); var mWindow = window; window.document.body.innerHTML = document.getElementById("form").innerHTML;
//字体调整 $("input,label,select,textarea,radio-inline").css("font-size", "8px"); $("label").css("font-weight","lighter"); mWindow.print(); } } var windowClose = function() { window.opener = null; window.open(‘‘, ‘_self‘); window.close(); }; //将表单中的数据进行绑定,便于html()的时候获取到 function bindData(){ $("input").each(function(){ $(this).attr(‘value‘,$(this).val()); }); $("input[type=‘radio‘]:checked").each(function(){ $(this).attr(‘checked‘, true); }); $("select option:selected").each(function() { $(this).attr(‘selected‘, true); }); //搞定 textarea $("textarea").each(function() { $(this).html($(this).val()); }); } </script> <style type="text/css" media=print> .Noprint{display : none } </style> <center class="Noprint"> <p class="Noprint"> <OBJECT id="wb" height="0" width="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" name="wb"></OBJECT> <input type=button value="打印" onclick="printIt()"> <input type=button value="关闭" onClick="windowClose()"> <br/> </p> </center>
然后在主页面引入即可
<title>打印</title> <%@include file="/avicit/ims/hr/common/print/print.jsp"%>