本文整理汇总了C#中System.Windows.Forms.HtmlElement.InsertAdjacentElement方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlElement.InsertAdjacentElement方法的具体用法?C# HtmlElement.InsertAdjacentElement怎么用?C# HtmlElement.InsertAdjacentElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.HtmlElement
的用法示例。
在下文中一共展示了HtmlElement.InsertAdjacentElement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddDivMessage
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);
}
}