gpt4 book ai didi

c# - 点击网页链接

转载 作者:太空宇宙 更新时间:2023-11-03 16:28:51 24 4
gpt4 key购买 nike

首先,抱歉我的英语不好。

问题很简单。我想用 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++;
}

它想要点击(我看到它在调试中发生,当我点击一个消息框时,消息框出现),但网页没有反应。

这是网页上 标签中的 html 代码:

<b><a href="" onclick="OnPhoenixRead('/mail/MessageRead?sid=7613BA4BF987D55FD171D53FAA24A259C7FDE435&amp;userid=*******&amp;seq=+Q&amp;auth=+A&amp;srcfolder=INBOX&amp;uid=3291&amp;srch=0&amp;style=default'); return false">Doorgest: testing 2</a></b>

所以它不会以某种方式点击文本...(或不会激活 onclick 事件处理程序)

如何使程序按预期运行?

提前致谢:D废话

编辑 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">&nbsp;<a href="" onclick="NavA('/mail/MessageSort?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&amp;userid=marcmeesters%40telfort.nl&amp;seq=+Q&amp;auth=+A&amp;srcfolder=INBOX&amp;sort=1&amp;style=default&amp;start=100&amp;end=1'); return false">Van&nbsp;</a>&nbsp;</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&amp;userid=marcmeesters%40telfort.nl&amp;seq=+Q&amp;auth=+A&amp;srcfolder=INBOX&amp;sort=5&amp;style=default&amp;start=100&amp;end=1'); return false">Onderwerp&nbsp;</a>&nbsp;</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&amp;userid=marcmeesters%40telfort.nl&amp;seq=+Q&amp;auth=+A&amp;srcfolder=INBOX&amp;sort=7&amp;style=default&amp;start=100&amp;end=1'); return false">Ontvangen&nbsp;</a>&nbsp;</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&amp;userid=marcmeesters%40telfort.nl&amp;seq=+Q&amp;auth=+A&amp;srcfolder=INBOX&amp;sort=9&amp;style=default&amp;start=100&amp;end=1'); return false">Grootte&nbsp;</a>&nbsp;</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">&nbsp;&nbsp;<b><a href="" onclick="OnPhoenixRead('/mail/MessageRead?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&amp;userid=marcmeesters%40telfort.nl&amp;seq=+Q&amp;auth=+A&amp;srcfolder=INBOX&amp;uid=3330&amp;srch=0&amp;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">&nbsp;&nbsp;<b><a href="" onclick="OnPhoenixRead('/mail/MessageRead?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&amp;userid=marcmeesters%40telfort.nl&amp;seq=+Q&amp;auth=+A&amp;srcfolder=INBOX&amp;uid=3330&amp;srch=0&amp;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">&nbsp;&nbsp;<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">&nbsp;&nbsp;<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>

最佳答案

改变说

的行
HtmlElementCollection links = Frame_A.Document.GetElementsByTagName("b");

HtmlElementCollection links = Frame_A.Document.GetElementsByTagName("a");

您将链接设置为等于所有带有粗体标记的元素。因为链接在粗体标签内,所以 innertext 条件通过。然后你试图点击一个粗体标签,这显然什么都不做。

关于c# - 点击网页链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11547021/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com