html页面局部打印


首先要把要打印的内容放在一个div里:我要打印的都放进id为:information1里面。

<div id="information1">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div id="info" class="x_content">

                                <img src="/qr/qrcode?content=${qrid}"/>

                                <h3>票类型:${ticktype}</h3>
                                <h3>票价格:${price}元</h3>

                            </div>

                        </div>
                    </div>
                    </div>

然后写个script

<script type=text/javascript>

        function printdata() {

            window.document.body.innerHTML=window.document.getElementById("information1").innerHTML;
            window.print();

        }
</script>

最后再用一个按钮 onclick这个方法

<input type="button"  class="btn btn-primary" value="打印" onclick="printdata()"/>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM