Scrollable Height of System.Windows.Controls.WebBrowser

﹥>﹥吖頭↗ 提交于 2019-12-11 05:48:15

问题


I am using the System.Windows.Controls.WebBrowser control, and I need to get the height of the rendered html document. (Not the height of the control, the height of the content)

The only height value I've found is WebBrowser.Document.body.offsetheight. However, this is the same value as the control's height.

I know the height of the page must be stored someplace since the scroll bar knows the value.

Everything I find in my searching has been about the Windows.Forms.WebBrowser.


回答1:


Add COM reference "Microsoft HTML Object Library" to the project, and use this:

mshtml.HTMLDocument doc = (mshtml.HTMLDocument)this.Browser1.Document;
mshtml.IHTMLElement2 elem = (mshtml.IHTMLElement2)doc.activeElement;
int height = elem.scrollHeight;


来源:https://stackoverflow.com/questions/18906381/scrollable-height-of-system-windows-controls-webbrowser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!