【发布时间】:2018-04-27 22:31:01
【问题描述】:
我真的很难浏览HTMLDocument 类中的所有属性。我有一个网页正在加载到嵌入在 Window 中的 WPF WebBrowser 中。我有一个类似的活动
private void _browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
HTMLDocument document = (HTMLDocument) this._browser.Document;
if (document.body != null)
{
this.Height = //get the div with the id 'wrapper' and get it's height
}
}
基本上。当页面完成导航后,我想获取 HTML 中特定分隔线的高度。
下面是 HTML 的样子:
<html lang="en-US">
<head>…</head>
<div id = "wrapper">…</div>
<body blah blah blah>…</body>
</html>
我似乎找不到这个 HTML,虽然它在 HTMLDocument 类中。我想获取此分隔线的高度并将窗口高度设置为此分隔线的高度加上按钮和其他所需的其他空间。
我应该在哪里搜索?
一开始我在尝试
HTMLDocument document = (HTMLDocument) this._browser.Document;
this.Height= document.body.offsetHeight
但这远非正确,而且我似乎找不到任何我读过的HTMLElement 类型的东西,您可以在其中访问个人HTMLElements。
如果您以前使用过这个课程或者可以看到我哪里出错了,我们将不胜感激。
【问题讨论】: