locked
Automatically Scrolling a WebView RRS feed

  • Question

  • Hi, in a WP8.1 App I'm currently developing, I need to display HTML content (a simple webpage) to the user. I also roughly know how far (in %) the user has already read the page, so I would like to automatically scroll it down to that % of its height.

    I currently use a WebView component to display the HTML page, but I cannot get to automatically scroll it. There doesn't seem to be a function for it, and I could not get a reference of a ScrollViewer wrapping it (if there is one in the first place).

    Any idea how to do this?

    Thanks,
    TB
    Thursday, October 9, 2014 8:29 PM

Answers

  • Hi Timothep,

    We can InvokeScriptAsync some javascript code into WebView for instance "window.scrollBy(20,100)" to scroll the HTML content to a correct place.

    webView.InvokeScriptAsync("eval", new string[] { "window.ScrollBy(20,100);"});

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Saturday, October 18, 2014 5:56 AM

All replies

  • Friday, October 10, 2014 8:02 AM
  • Thanks for the answer.

    Unfortunately I cannot find anything that would even start to look like a scroll-relevant function or property on a WebView I could hook onto...

    Friday, October 10, 2014 8:26 AM
  • Hi Timothep,

    We can InvokeScriptAsync some javascript code into WebView for instance "window.scrollBy(20,100)" to scroll the HTML content to a correct place.

    webView.InvokeScriptAsync("eval", new string[] { "window.ScrollBy(20,100);"});

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Saturday, October 18, 2014 5:56 AM