首先,对不起我的英语不好。
问题很简单。我想点击 C# 的链接(Windows 窗体)
这是我使用的代码:
int number_to_show = Convert.ToInt32(listView1_new_message.SelectedItems[0].SubItems[4].Text);
int a_to_click = (number_to_show * 5) + 2;
string titel_of_message = listView1_new_message.SelectedItems[0].SubItems[1].Text;
HtmlWindow SContentFrame = webBrowser1.Document.Window.Frames[1];
HtmlWindow Frame_A = SContentFrame.Document.Window.Frames[2];
HtmlElementCollection links = Frame_A.Document.GetElementsByTagName("b");
int link_counter = 0;
foreach (HtmlElement link in links) {
if (link_counter == a_to_click && link.InnerText.Equals(titel_of_message)) {
link.InvokeMember("Click");
}
link_counter++;
}
它想点击(我看到它发生在调试中,当我点击一个消息框时,会出现消息框),但网页没有反应。
这是在网页上的标签:
<b><a href="" onclick="OnPhoenixRead('/mail/MessageRead?sid=7613BA4BF987D55FD171D53FAA24A259C7FDE435&userid=*******&seq=+Q&auth=+A&srcfolder=INBOX&uid=3291&srch=0&style=default'); return false">Doorgest: testing 2</a></b>
所以不知何故它没有点击文本......(或没有激活 onclick 事件处理程序)
我怎样才能使程序按应有的方式工作?
在此先感谢:D TWCrap
编辑 1 这是保存所有电子邮件的表格的一段代码....
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tbody><tr valign="middle" bgcolor="#f0f0f0">
<td width="20" align="center"><input type="checkbox" name="CheckAll" onclick="ToggleCheckAll()"></td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center"><font face="Verdana" size="2" color="#141F78"><b>!!</b></font></td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center"><img src="/graphics/telfort/mail-icon.gif" width="20" height="20" border="0" alt=""></td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center"><img src="/graphics/telfort/attachments.gif" width="20" height="21" border="0" alt=""></td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td class="mailtitlebar"> <a href="" onclick="NavA('/mail/MessageSort?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&userid=marcmeesters%40telfort.nl&seq=+Q&auth=+A&srcfolder=INBOX&sort=1&style=default&start=100&end=1'); return false">Van </a> </td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td class="mailtitlebar"><a href="" onclick="NavA('/mail/MessageSort?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&userid=marcmeesters%40telfort.nl&seq=+Q&auth=+A&srcfolder=INBOX&sort=5&style=default&start=100&end=1'); return false">Onderwerp </a> </td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td class="mailtitlebar"><a href="" onclick="NavA('/mail/MessageSort?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&userid=marcmeesters%40telfort.nl&seq=+Q&auth=+A&srcfolder=INBOX&sort=7&style=default&start=100&end=1'); return false">Ontvangen </a> </td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td class="mailtitlebar"><a href="" onclick="NavA('/mail/MessageSort?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&userid=marcmeesters%40telfort.nl&seq=+Q&auth=+A&srcfolder=INBOX&sort=9&style=default&start=100&end=1'); return false">Grootte </a> </td>
</tr>
<tr><td colspan="15" bgcolor="#f0f0f0"><img src="/graphics/telfort/null.gif" height="1" width="1"></td></tr><!-- Message List Head --><!-- Message List --><tr valign="middle">
<td width="20" align="center" bgcolor="#f0f0f0"><input type="checkbox" name="msguid" value="3330"></td>
<td width="1" bgcolor="#f0f0f0"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center">
<script>
var stat = '<IMG SRC="/graphics/priority_normal.gif" BORDER=0 width="10" height="18"><IMG SRC="/graphics/new.gif" BORDER=0 width="20" height="18"><IMG SRC="/graphics/attach_none.gif" BORDER=0 width="8" height="18">';
</script>
<script>
if (stat.indexOf('high.gif') > -1 )
{
document.write ('<font face="Tahoma" size="2" color="#141D7C"><b>!!</b></font>');
}
else if (stat.indexOf('low.gif') > -1 )
{
document.write ('<font face="Tahoma" size="2" color="#141D7C"><b>!</b></font>');
}
</script></td>
<td width="1" bgcolor="#f0f0f0"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center" bgcolor="#ffffff"><script>
if (stat.indexOf('new.gif') > -1)
{
document.write ('<img src="/graphics/telfort/mail-icon.gif" width="20" height="20" border="0" alt="">');
}
else if (stat.indexOf('deleted.gif') > -1)
{
document.write ('<img src="/graphics/telfort/cancel.gif" width="20" height="20" border="0" alt="">');
}
else if (stat.indexOf('replied.gif') > -1)
{
document.write ('<img src="/graphics/telfort/reply.gif" width="20" height="20" border="0" alt="">');
}
else
{
document.write ('<img src="/graphics/telfort/mailopen-icon.gif" width="20" height="20" border="0" alt="">');
}
</script><img src="/graphics/telfort/mail-icon.gif" width="20" height="20" border="0" alt=""></td>
<td width="1" bgcolor="#ffffff"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center" bgcolor="#ffffff"><script>
if (stat.indexOf('attach.gif') > -1)
{
document.write ('<img src="/graphics/telfort/attach-icon.gif" width="20" height="20" border="0" alt="">');
}
</script></td>
<td width="1" bgcolor="#ffffff"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td bgcolor="#ffffff" class="mailtxt"> <b><a href="" onclick="OnPhoenixRead('/mail/MessageRead?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&userid=marcmeesters%40telfort.nl&seq=+Q&auth=+A&srcfolder=INBOX&uid=3330&srch=0&style=default'); return false">Tweakers.net Nieuwsbrief</a></b></td>
<td width="1" bgcolor="#ffffff"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td bgcolor="#ffffff" class="mailtxt"> <b><a href="" onclick="OnPhoenixRead('/mail/MessageRead?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&userid=marcmeesters%40telfort.nl&seq=+Q&auth=+A&srcfolder=INBOX&uid=3330&srch=0&style=default'); return false">Samsung toont info eerste Windows Phone ...</a></b></td>
<td width="1" bgcolor="#ffffff"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td bgcolor="#ffffff" class="mailtxt"> <b>jul 30</b></td>
<td width="1" bgcolor="#ffffff"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td bgcolor="#ffffff" class="mailtxt"> <b>42.9 KB</b></td>
</tr>
<tr><td colspan="15" bgcolor="#bbbdbf"><img src="/graphics/telfort/null.gif" height="1" width="1"></td></tr>
<!-- Message List end--><tr valign="middle">
<td width="20" align="center" bgcolor="#f0f0f0"><input type="checkbox" name="msguid" value="3329"></td>
<td width="1" bgcolor="#f0f0f0"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center">
<script>
var stat = '<IMG SRC="/graphics/priority_normal.gif" BORDER=0 width="10" height="18"><IMG SRC="/graphics/new.gif" BORDER=0 width="20" height="18"><IMG SRC="/graphics/attach_none.gif" BORDER=0 width="8" height="18">';
</script>
<script>
if (stat.indexOf('high.gif') > -1 )
{
document.write ('<font face="Tahoma" size="2" color="#141D7C"><b>!!</b></font>');
}
<!-- Message List end--></tbody></table>