HtmlElementInsertionOrientation 列挙体
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public Enumeration HtmlElementInsertionOrientation

メンバ名 | 説明 | |
---|---|---|
AfterBegin | 現在の要素の後、かつ、現在の要素に含まれるその他すべてのコンテンツの前に要素を挿入します。 | |
AfterEnd | 現在の要素の後、かつ、現在の要素に含まれるその他すべてのコンテンツの後に要素を挿入します。 | |
BeforeBegin | 現在の要素の前に要素を追加します。 | |
BeforeEnd | 現在の要素の後に要素を追加します。 |

次のコード例では、ユーザーが ADatum.com サーバー以外から表示するすべてのページの最上部に、DIV 要素を挿入します。この例では、フォームに WebBrowser1 という名前の WebBrowser コントロールが含まれている必要があります。また、名前空間 System.Text.RegularExpressions をインポートする必要もあります。
public void AddDivMessage() { Uri currentUri = new Uri(webBrowser1.Url.ToString()); String hostName = null; // Ensure we have a host name, and not just an IP, against which to test. if (!(currentUri.HostNameType == UriHostNameType.Dns)) { DnsPermission permit = new DnsPermission(System.Security.Permissions.PermissionState.Unrestricted); permit.Assert(); IPHostEntry hostEntry = System.Net.Dns.GetHostEntry(currentUri.Host); hostName = hostEntry.HostName; } else { hostName = currentUri.Host; } if (!hostName.Contains("adatum.com")) { AddTopPageMessage("You are viewing a web site other than ADatum.com. " + "Please exercise caution, and ensure your Web surfing complies with all " + "corporate regulations as laid out in the company handbook."); } } private void AddTopPageMessage(String message) { if (webBrowser1.Document != null) { HtmlDocument doc = webBrowser1.Document; // Do not insert the warning again if it already exists. HtmlElementCollection returnedElems = doc.All.GetElementsByName("ADatumWarningDiv"); if ((returnedElems != null) && (returnedElems.Count > 0)) { return; } HtmlElement divElem = doc.CreateElement("DIV"); divElem.Name = "ADatumWarningDiv"; divElem.Style = "background-color:black;color:white;font-weight:bold;width:100%;"; divElem.InnerText = message; divElem = doc.Body.InsertAdjacentElement(HtmlElementInsertionOrientation.AfterBegin, divElem); } }

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- HtmlElementInsertionOrientation 列挙体のページへのリンク