HtmlElement.SetAttribute メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As HtmlElement Dim attributeName As String Dim value As String instance.SetAttribute(attributeName, value)

HTML における属性とは、要素に割り当てられた有効な名前と値のペアです。HtmlElement は、すべての要素に共通する属性のみを公開し、一部の要素にのみ当てはまる属性は公開しません。たとえば、SRC は IMG タグの定義済みの属性ですが、DIV タグの属性ではありません。GetAttribute と SetAttribute を使用すると、マネージ DOM で公開されていない属性を操作できます。
attributeName が要素の定義済み属性でない場合、SetAttribute は、その属性を要素の新しい属性として定義します。
GetAttribute と SetAttribute では、大文字と小文字が区別されません。
HtmlElement に class 属性を設定するには、SetAttribute の第 1 引数を指定するときに、この属性を className として参照する必要があります。

次のコード例は、現在のドキュメントに新しい IMG 要素を追加し、SetAttribute を使用してそのイメージの SRC 属性を設定します。
HtmlElement bodyElement = null; private void SetBody() { if (webBrowser1.Document != null) { HtmlDocument doc = webBrowser1.Document; bodyElement = doc.Body; //bodyElement.Error += new HtmlElementEventHandler(HandleError); } } private void HandleError(Object sender, HtmlElementEventArgs e) { //System.Diagnostics.EventLog.WriteEntry("Custom Application", "Scripting error occurred: " & _ //e. }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からHtmlElement.SetAttribute メソッドを検索する場合は、下記のリンクをクリックしてください。

- HtmlElement.SetAttribute メソッドのページへのリンク