当前位置:编程学习 > 网站相关 >>

Web打印

<html>
<head>
    <title>打-印-预-览</title>   
    <script language="javascript" type="text/javascript">
    <!--
        //弹窗打印函数
        function printPage(id) {
            var needHTML = document.getElementById(id).innerHTML;
            //alert(needHTML);
            var OpenWindow = window.open("print.htm", "abc", "height=100, width=150, top=0, left=0,易做图=no,menubar=no, scrollbars=no, resizable=no, location=no, status=no");
            OpenWindow.document.write("<html>");
            OpenWindow.document.write("<head>");
            OpenWindow.document.write("<title>打印</title>");
            OpenWindow.document.write("</head>");
            OpenWindow.document.write("<body>");
            OpenWindow.document.write(needHTML);
            OpenWindow.document.write("</body>");
            OpenWindow.document.write("</html>");
            OpenWindow.document.close();
            OpenWindow.document.location.reload();
            OpenWindow.print();
        }
    -->
    </script>
</head>
<body>
    <div id="aidd2008">
        <div id="div0">
            不打印的内容
        </div>
        <div id="div1">
            <input type="button" value="打印" onclick="printPage('needPrint')" />
        </div>
        <div id="needPrint">
            需要打印的内容</div>
    </div>
</body>
</html>
 
跳出新窗体,打印需要打印的内容。
页眉页脚边距的问题还是很头痛。

   Eat to live, but do not live to eat.
 

 

摘自 张银的博客

 
 

补充:Web开发 , 其他 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,