如何获取web浏览器元素';s css样式
本文关键字:样式 css 元素 浏览器 何获取 获取 web | 更新日期: 2023-09-27 18:29:34
我的web浏览器中有一个类似下面的页面,我想获取style
atribute值。我试过了:
HtmlElement ele = webBrowser1.Document.GetElementById("foo");
MessageBox.Show(ele.GetAttribute("style"));
但它输出:
System.__ComObject
为什么它输出System.__ComObject
类型,我该如何处理它?
HTML页面:
<div id="foo" style="display:block;">
a
</div>
ele.Style
会有帮助的。
ele.GetAttribute("Style")
不起作用,因为返回字符串,所以它不能说比这更多的是一个对象,而ele.Style
返回CssStyleCollection
。
var e = document.getElementById('foo');
var css = window.getComputedStyle(e,null).getPropertyValue("display");
alert(css);