码迷,mamicode.com
首页 > 其他好文 > 详细

文件和打印的技巧-单独打开一个页面来完成打印功能

时间:2016-09-29 21:32:19      阅读:134      评论:0      收藏:0      [点我收藏+]

标签:

——————————————————————————

<script type="text/javascript">        
            function doPrint(){
                window.open(‘print.html‘);
            }
        </script>

————————————————————————

<body style="text-align:center">
        <form>
            <label>姓名:</label>
            <input name="the_name" type="text"/>
            <br>
            <label>年龄:</label>
            <input name="age" type="text"/>
            <br>
            <label>性别:</label>
            <input name="gender" type="text"/>
            <br>
            <input type="button" onclick="doPrint();" value="打印"/>
        </form>
    </body>

————————————————————————

print.html :

<script type="text/javascript">        
            function init(){
                var w = window.opener;
                var f = w.document.forms[0];
                var str = ‘‘;
                str += ‘姓名:‘ + f[‘the_name‘].value;
                str += ‘,年龄: ‘ + f[‘age‘].value;
                str += ‘,性别: ‘ + f[‘gender‘].value;
                document.body.innerHTML = str;
            }
</script>   

——————————————————————————

文件和打印的技巧-单独打开一个页面来完成打印功能

标签:

原文地址:http://www.cnblogs.com/hanxuming/p/5920921.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!