使用javascript打印包含完整CSS样式和图像样式的网页 [英] Print web page including complete CSS styles and images styles using javascript

查看:83
本文介绍了使用javascript打印包含完整CSS样式和图像样式的网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用javascript打印网页(比如带有样式,图像和数据表的内容)。



我有什么试过:



使用window.print()效果不佳。没有打印网页中的图像和样式。

解决方案

你好,



你必须在@media打印内写一组css规则或类。

  @ media   print  {
body {
- webkit -print-color-adjust exact;
}
other-classes-come-here {
}
}


How can i print a web page (say a div of contents with styles, images and table of data) using javascript.

What I have tried:

using window.print() didn't worked well. Didn't print images and styles as it is in web page.

解决方案

Hello,

You must have to write set of css rules or class inside the @media print.

@media print {
    body {
        -webkit-print-color-adjust: exact;
    }
    .other-classes-comes-here {
    }
}


这篇关于使用javascript打印包含完整CSS样式和图像样式的网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆