【发布时间】:2012-01-15 00:11:13
【问题描述】:
我正在使用 WinForms C# 3.5 WebBrowser
我正在尝试访问以下 HTML 文档中的 head 元素:
this.webBrowserTest.DocumentText = @”<html>
<head>
<title>Test JavaScript WinForms</title>
<meta name="description" content="Test WinForms" />
</head>
<body></body>
</html>”
HtmlElementCollection headCollection = webBrowserTest.Document.GetElementsByTagName("HEAD");
HtmlElement head = headCollection[0]
headCollection[0] 被传递为null
有人知道怎么回事吗?
谢谢
【问题讨论】:
-
您是否等到 DocumentCompleted?设置 DocumentText 会导致当前文档被转储,并且在异步导航完成对新文档的解析之前,文档将不可用。
标签: c# .net html winforms webbrowser-control