I want to set the control height WebBrowserdynamically, depending on the height of the content.
My scenario: on this particular view, I have different elements - Image, MediaElement, etc. and meanwhile the rich text that appears in this WebBrowser control. To achieve a single scroll, I wrapped all the content in scrollview and turned off scrolling in the webbrowser control.
I currently have a method JavaScriptthat is called when the body has loaded and sends the height information to C#codebehind, but the calculated height is incorrect.
My hack today is basically to multiply the return value by 1.75 .
In the page title, 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 tag body.
<body onLoad="SendDataToPhoneApp()" style="margin:0px;padding:0px;">
My JavaScriptfunctions:
<script>
function getDocHeight() {
return document.getElementById('pageWrapper').offsetHeight;
}
function SendDataToPhoneApp() {
window.external.Notify('' + getDocHeight());
}
</script>
pageWrapperis a direct descendant body.
source
share