Reputation: 16724
I have a page like the below in my web browser that I want to get the style
atributte value. I tried:
HtmlElement ele = webBrowser1.Document.GetElementById("foo");
MessageBox.Show(ele.GetAttribute("style"));
but it output:
System.__ComObject
Why does it output a System.__ComObject
type and how do I handle it?
HTML page:
<div id="foo" style="display:block;">
a
</div>
Upvotes: 3
Views: 3560
Reputation: 366
var e = document.getElementById('foo');
var css = window.getComputedStyle(e,null).getPropertyValue("display");
alert(css);
Upvotes: 4
Reputation: 18997
ele.Style
Will help.
ele.GetAttribute("Style")
won't work because returns string, so it can't say more than that is an object, while ele.Style
returns CssStyleCollection
.
Upvotes: 4