![](/img/trans.png)
[英]document styleSheets get all styles on an element with pseudo-selector
[英]Get the background styles of a pseudo element
Internet Explorer 8不允许打印背景图像。
不幸的是,我被要求做这项工作。
在一些必须可打印的伪元素中存在“重要”图像。
我认为有可能将这些背景图像转换为<img/>
元素,但似乎无法在Internet Explorer 8中读取伪元素的样式,因为它不支持getComputedStyle
。
有什么好主意吗?
有关:
https://developer.mozilla.org/en/docs/Web/API/window.getComputedStyle
http://caniuse.com/getcomputedstyle/embed
SO“获取伪元素样式值”
这应该工作:
var img = window.getComputedStyle(
document.querySelector('.element'), ':before'
).getPropertyValue('background');
编辑 :我有一个不使用querySelector
的工作小提琴 :
var img = window.getComputedStyle(
$(".element")[0], ':before'
).getPropertyValue('background');
基本上,您只想在getComputedStyle
获取元素作为第一个参数;
但是仍然没有修复IE 8的要求,因为getComputedStyle
不支持getComputedStyle
,但是...... 这个问题可能会提供答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.