通过滚动在XAML检测的WebView高度 [英] Detecting WebView Height via Scrolling in XAML
问题描述
我真正需要的是能制定出一段HTML的有多高是一个给定的WebView
里面。这是非常重要的项目,我想建立。我知道这不是马上可能的,但我可以决定是否对的WebView我也许能增加观的高度,直到它消失存在一个滚动条。
I really need to be able to work out how tall a piece of HTML is inside a given WebView
. It's pretty much crucial to the project I'm trying to build. I know it's not immediately possible but I could determine whether a scrollbar existed on a WebView I might be able to increase the height of the view until it disappeared.
在这个有什么想法?或任何其他解决方案/建议吗?我看着使用HTMLAgilityPack转换它一个TextBlock(现移植到地铁),但HTML是太复杂。
Any thoughts on this? Or any alternative solutions / suggestions? I looked into converting it for a TextBlock using the HTMLAgilityPack (now ported to Metro) but the HTML is too complex for that.
推荐答案
如果您对HTML控件,添加这个JavaScript:
If you have control over the HTML, add this javascript:
function getDocHeight() {
var D = document;
return Math.max(
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
Math.max(D.body.clientHeight, D.documentElement.clientHeight)
);
}
(从的http://james.padolsey.com/javascript/get-document-height-cross-browser/ )
和调用这个而非警报
:
window.external.notify(getDocHeight());
然后实施 ScriptNotify
事件:
这篇关于通过滚动在XAML检测的WebView高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!