打印

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script>
        function PrintArticle() {
            var pc = document.getElementById("<%=PrintContent.ClientID%>");
            var pw = window.open('', '', 'width=500,height=400');
            pw.document.write('<html>');
            pw.document.write('<head>');
            pw.document.write('<title>ASP.NET網頁打印測試</title>');
            pw.document.write('</head>');
            pw.document.write('<body>');
            pw.document.write(pc.innerHTML);
            pw.document.write('</body>');
            pw.document.write('</html>');
            pw.document.close();
            setTimeout(function () {
                pw.print();
            }, 0);
            return false;
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div id="PrintContent" runat="server">
            ASP.NET網頁打印測試<br />
            內容內容內容內容內容內容內容內容內容內容內容內容內容<br />
            內容內容內容內容內容內容內容內容內容內容內容內容內容<br />
            內容內容內容內容內容內容內容內容內容內容內容內容內容<br />
            內容內容內容內容內容內容內容內容內容內容內容內容內容<br />
            內容內容內容內容內容內容內容內容內容內容內容內容內容<br />
            內容內容內容內容內容內容內容內容內容內容內容內容內容<br />
            內容內容內容內容內容內容內容<br />
        </div>
        <asp:Button ID="btnPrint" runat="server" Text="打印" OnClientClick="return PrintArticle();" />
    </form>
</body>
</html>

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章