<script type="text/javascript">
(function (bool) {
//严重感谢M2前辈
if (bool) {
HTMLElement.prototype.__defineGetter__("currentStyle", function () {
//getComputedStyle方法参数一是目标对象,参数二是具体属性。。。把注释对换下就知道了。。
//return this.ownerDocument.defaultView.getComputedStyle(this, ":first-line");
return this.ownerDocument.defaultView.getComputedStyle(this, null);
});
}
})(/Firefox/.test(window.navigator.userAgent));
</script>
<style type="text/css">
div {
color:#000000;
}
div:first-line {
color:#0000FF;
}
</style>
<div οnclick="alert(this.currentStyle.color)">DIV对象<br />第二行</div>
(function (bool) {
//严重感谢M2前辈
if (bool) {
HTMLElement.prototype.__defineGetter__("currentStyle", function () {
//getComputedStyle方法参数一是目标对象,参数二是具体属性。。。把注释对换下就知道了。。
//return this.ownerDocument.defaultView.getComputedStyle(this, ":first-line");
return this.ownerDocument.defaultView.getComputedStyle(this, null);
});
}
})(/Firefox/.test(window.navigator.userAgent));
</script>
<style type="text/css">
div {
color:#000000;
}
div:first-line {
color:#0000FF;
}
</style>
<div οnclick="alert(this.currentStyle.color)">DIV对象<br />第二行</div>