js 打印功能

js 打印功能

<html>
<head>
    <title>打印测试</title>
    <script type="text/javascript">
        function printDocument() {
            document.all.btnPrint.style.display = 'none';
            window.print();
            document.all.btnPrint.style.display = '';
        }
    </script>
</head>
<body>
    <div>
        打印测试1<br>
        打印测试2<br>
        打印测试3
    </div>

    <a id="btnPrint" href="#" onclick="printDocument()">打印</a>
</body>
</html>


热门推荐