I want to set the height of WebBrowser
control dynamically, depending on the content height.
My scenario is: On that specific view I have different elements - an Image, MediaElement etc. and between those rich text that is presented in that WebBrowser control. To achieve unified scrolling I have wrapped all content in a scrollview and disabled scrolling on the webbrowser control.
Currently I have a JavaScript
method that gets called when body has done loading and sends the height information to C#
codebehind but the calculated height is incorrect.
My hack today is to basically multiply the returned value with about 1.75.
In the page head I have the following meta tags:
<meta charset='Windows-1257'>
<meta name='viewport' content='width=device-width' />
<meta name='viewport' content='user-scalable=no' />
<meta name='viewport' content='initial-scale = 1.0' />
<meta name='HandheldFriendly' content='true' />"
<meta name='target-densitydpi=device-dpi' />
This is my body
tag.
<body onLoad="SendDataToPhoneApp()" style="margin:0px;padding:0px;">
My JavaScript
functions:
<script>
function getDocHeight() {
return document.getElementById('pageWrapper').offsetHeight;
}
function SendDataToPhoneApp() {
window.external.Notify('' + getDocHeight());
}
</script>
pageWrapper
is a direct child of body
.