zoukankan      html  css  js  c++  java
  • C#点击打开webbrowser中网页中的超链接

    1:使用webbrowser的 links方法

                //if (webBrowser1.Document != null)
                //{
                //    int j = webBrowser1.Document.Links.Count;
                //    for (int i = 0; i < j ; i++)
                //    {
                //        webBrowser1.Document.Links[i].InvokeMember("Click");
                //    }
                //}

    2: 使用了 HtmlDocument 的方法

          HtmlDocument doc = this.webBrowser1.Document;

                for (int i = 0; i < doc.All.Count; i++)
                {
                    if (doc.All[i].TagName == "A" || doc.All[i].TagName == "a")
                    {
                        HtmlElement elem = doc.All[i];
                        if (elem.OuterText == "自动收录网站")
                        {
                            elem.InvokeMember("Click");
                        }
                    }
                }

    还有一种方法自己测试了一半就没做了.因为时间很紧,写下来只要做以后的参考.          

  • 相关阅读:
    leetcode319
    leetcode516
    leetcode46
    leetcode337
    leetcode287
    leetcode328
    leetcode241
    2018-6-30-dotnet-设计规范-·-抽象类
    2018-6-30-dotnet-设计规范-·-抽象类
    2018-8-10-WPF-如何画出1像素的线
  • 原文地址:https://www.cnblogs.com/yeye518/p/2231642.html
Copyright © 2011-2022 走看看