当前位置 : 主页 > 编程语言 > java >

jsp打印

来源:互联网 收集:自由互联 发布时间:2021-06-25
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()">&nbsp;&nbsp; <input type=button value="关闭" onClick="windowClose()">&nbsp;&nbsp;<br/> </p> </center>

然后在主页面引入即可

<title>打印</title>
<%@include file="/avicit/ims/hr/common/print/print.jsp"%>
网友评论