最近几天我一直在尝试从 WebBrowser
控件的 Document 属性中获取网页的高度。
以下是我的最新尝试。
HtmlElementCollection children = webBrowser.Document.All;
int maxOffset = 0;
foreach (HtmlElement child in children) {
int bottom = 0;
bottom = child.OffsetRectangle.Bottom;
if (bottom > maxOffset) {
maxOffset = bottom;
pageHeight = maxOffset;
}
}
我试图通过找到页面中最低元素的底部偏移量来计算页面的最大高度。
问题是这会在大多数情况下超出页面实际长度约500px。
有人有任何想法吗?我简直无法相信获取页面高度如此困难!