代码之家  ›  专栏  ›  技术社区  ›  luvieere

为什么HtmlElement的GetAttribute()方法返回“mshtml.HTMLInputElementClass类“而不是属性的值?

  •  2
  • luvieere  · 技术社区  · 14 年前

    HtmlElement GetAttribute() mshtml.HTMLInputElementClass 当我试图获取窗体的 action 属性?

    HtmlElementCollection elements = webBrowser1.Document.Forms;
       foreach (HtmlElement element in elements)
            MessageBox.Show(element.GetAttribute("action") + "");
    
    1 回复  |  直到 12 年前
        1
  •  3
  •   sharp    14 年前

    这似乎是一个IE错误。

    添加对的引用微软.mshtml

    if(element.GetAttribute("action").Equals("mshtml.HTMLInputElementClass"))
    {
        mshtml.IHTMLFormElement iForm = (mshtml.IHTMLFormElement)element.DomElement; 
        string action = iForm.action;
    }
    

    希望对您有所帮助:)