简体   繁体   English

使用javascript的打印功能打印弹出窗口

[英]Print the popup using print function of javascript

i have a modal popup "gatepass". 我有一个模式弹出窗口“ gatepass”。 when i click on generate , it generates this gatepass. 当我单击generate时,它会生成此Gatepass。 In this gatepass i have two buttons close and print . 在此通行证中,我有两个按钮关闭并打印。 when i click on print button, i want the gatepass to print and not the background. 当我单击“打印”按钮时,我希望门禁打印而不是背景。 please guide me , how can i do it? 请指导我,我该怎么办?

<html>
<head>
 <script src="js/calculateamt.js" type="text/javascript"></script>
      <link href="CSS/popup.css" rel="stylesheet" type="text/css">

</head>
<body>
   <fieldset id="gatepass" class="popup">
    <p align="center"><span style="size: 40px; font-size: 24px; alignment-adjust:middle">CASH RECIEPT</span></p>
    <table width="453" border="0" align="center" cellpadding="20px">
            <tr>
                <td width="188" height="51">RECIEPT NO : 
                    <label id="recno"><%=recieptno%></label></td>
                <td width="179">DATE : <label id="date"><%=date%></label></td>
            </tr>
            <tr>
                <td height="57">NAME : <label id="name" > <%=firstname%> <%=lastname%></label></td>
                <td>VILLAGE : <label id="village"> <%=vill%></label></td>
            </tr>
        </table>

        <p>&nbsp;</p>
        <table width="697" height="52" border="0" align="center" cellpadding="20px">
            <tr>
                <td width="205">AGREEMENT NO : <label id="agrno"> <%=agreno%></label> </td>
                <td width="149">LOT NO : <label id="lotno"><%=agreno%>/<%=bag%></label></td>
                <td width="151">BAGS : <label id="bags" ><%=bag%></label></td>
                <td width="174"> VEHICLE NO : <label id="vehicle"></label></td>
            </tr>
        </table>
        <p>&nbsp;</p>
        <table width="200" height="47" border="0" align="center" cellpadding="20px">
            <tr>
                <td> TOTAL AMOUNT : 
                    <label onloadstart="javascript:totalamt()" id="Totalamt" name ="total"></label></td>

            </tr>
        </table>
        <p align="center">
        <p align="center">
            <input type="button" name="Print" id="Print" value="PRINT" onClick="window.focus();window.print();">
            <input type="button" name="close" id="close" value="CLOSE" onClick = "closePopup();"  /> 

        <p>&nbsp;</p>
        <p>&nbsp;</p>
        <p>&nbsp;</p>

    </fieldset>

</body>
</html>

I suggest you reseach up on print style sheets 我建议您在打印样式表上进行研究

http://www.webdesignerdepot.com/2010/01/10-tips-for-better-print-style-sheets/ http://www.webdesignerdepot.com/2010/01/10-tips-for-better-print-style-sheets/

<link rel="stylesheet" type="text/css" href="print.css" media="print" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM