我想要获取网页中html元素的字体大小,例如<p>标签。即使对于没有style或class属性的元素,这也应该是有效的,因此它必须知道动态继承的css属性。
我尝试过html agilitypack,一个非常好的库,但它当然不考虑css渲染。也尝试了WPF网页浏览器,但它似乎不能获得每个元素的字体大小,并且对于许多元素,它返回一个百分比。
Javascript getComputedStyle()不适合,因为所有的都应该运行在服务器端。
有什么想法吗?
发布于 2013-10-28 19:01:05
试试这个:
Element.prototype.getStyle = function (prop) {
if (document.defaultView)
return document.defaultView.getComputedStyle(this, null)[prop];
else
return this.currentStyle[prop];
}呼叫:
document.getElementById("div1").getStyle("font-size");https://stackoverflow.com/questions/19632794
复制相似问题