私はこのHTMLコードを持っています
<div class="anc-style" onclick="window.open('./view.php?a=foo')"></div>
「onclick」属性の内容を抽出したいと思います。私は次のようなことを試みました:
div.GetAttribute("onclick").ToString();
理想的には文字列を生成します
"window.open('./view.php?a=foo')"
System.__ComObject を返します。
("onclick") を ("class") に変更することでクラスを取得できますが、onclick で何が起こっているのでしょうか?
HtmlElementCollection div = webBrowser1.Document.GetElementsByTagName("div");
for (int j = 0; j < div.Count; j++) {
if (div[j].GetAttribute("class") == "anc-style") {
richTextBox1.AppendText(div[j].GetAttribute("onclick").ToString());
}
}