Windows Phone 7 Web Browser Height

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.

+3
source share
1 answer

Try using document.body.clientHeight in your Javascript. You might also be lucky with your script if you build everything inside WebBrowser. You can put images in HTML, of course, and you can put an image of a replacement still frame for your MediaElement by switching to C # and, if necessary, load a real MediaElement.

+4
source

All Articles