JS 打印图片


在使用window.print()进行打印时,打印的内容可能会包含图片内容,此时的图片内容不能设置为背景图片,否则将无法再打印页面显示。

<!doctype html>
<html>
    <head>
        <title></title>
        <script type="text/javascript">
            function printfun(){
                window.print();
            }
        </script>
    </head>
    <body>
        <input type="button" value="打印" onclick="printfun()"><br/>
        下面设置的img图片:
        <div>
            <img src="images/moganna.png">
        </div>
        
        下面图片是背景图片:
        <div style="background: url('images/moganna.png'); width: 500px; height: 291px;">
        
        </div>
    </body> 
</html>

                                                                                                                    

 


免责声明!

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



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