在使用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>