0

要素に新しい属性を設定するのに問題があります。VS 2005 は、以下のコードで次のエラーを返します。

エラー 1 メソッド 'setAttribute' のオーバーロードは '2' 引数を取らない エラー 2 メソッド 'setAttribute' のオーバーロードは '2' 引数を取らない エラー 3 メソッド 'setAttribute' のオーバーロードは '2' 引数を取らない

何が問題になる可能性がありますか?

ありがとうございました!

try
{
   IHTMLElementCollection AllElements = document.all;
   foreach (IHTMLElement Element in AllElements)
   {                   
      if (Element.tagName.ToUpper() == "IMG")
      {   
         if (Element.offsetHeight <= 40 && Element.offsetHeight >= 20)
         {
            if (Element.offsetWidth <= 160 && Element.offsetWidth >= 130)
            {
               Element.setAttribute("width", Element.offsetWidth);
               Element.setAttribute("height", Element.offsetHeight);
               Element.setAttribute("src", "images/newimage.png");
            }
         }
      }
   }            
}   
catch (Exception e)
{
   string erro = e.Message;
   System.Windows.Forms.MessageBox.Show(erro);
}
4

1 に答える 1