【问题标题】:Object does not contain a definition for links and no extension method links accepting first arguments of type links对象不包含链接的定义,并且没有扩展方法链接接受链接类型的第一个参数
【发布时间】:2018-03-15 16:11:07
【问题描述】:
    private void UpdateWebsiteBrowser(string link)
    {
        int i = 0;
        if (MyBrowser.Document != null)
        {
            for (i = 0; i <= MyBrowser.Document.links.length - 1; i++)
            {
                if (string.Compare(HttpUtility.HtmlDecode(MyBrowser.Document.links.Item(i).href), HttpUtility.HtmlDecode(link), true) == 0)
                {
                   MyBrowser.Document.links.Item(i).Style.backgroundColor = "red";
                }
            }
        }
    }

MyBrowser.Document.Links 中的错误

对象不包含链接的定义

【问题讨论】:

    标签: c# wpf


    【解决方案1】:

    Document 的类型为 object - WebBrowser.Document,因此没有属性 linksLinks

    根据您的需要,您可以使用dynamic(例如参见How to get the Document's Title from a Web Browser control in wpf)或需要自己选择元素(How to get value from any tag in web browser control using wpf)或转换为mshtml.HTMLDocument

    【讨论】:

      猜你喜欢
      • 2023-03-13
      • 2019-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-03
      • 1970-01-01
      相关资源
      最近更新 更多