UWP WebView scrolling error

1

I making a simple news feed UWP app, using WebView to show the details of the news, for some reasons I need to use buttons to control it scroll up and down instead of using scrolling bar. But I have This error: Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME). the following is my code:

HTMLPage1.html

<body>
<div id="test" style="width: 600px;height: 400px;padding: 10px;margin: 10px;border: 1px solid black;overflow:scroll;font-size:15px;line-height:200px;">
    Content
</div>
<script type="text/javascript">
    function ScrollDownBtn()
    {
        test.scrollTop += 20;
    }

    function ScrollUpBtn()
    {
        test.scrollTop -= 20;
    }
</script>

MainPage.xaml

 <WebView x:Name="wv1"/>
<Button Name="test" Content="up" Click="test_Click" />
 <Button Name="test1" Content="down" Click="test1_Click"/>

MainPage.xaml.cs

 private async void test_Click(object sender, RoutedEventArgs e)
    {
          await wv1.InvokeScriptAsync("ScrollUpBtn", null);
    }

    private async void test1_Click(object sender, RoutedEventArgs e)
    {
        await wv1.InvokeScriptAsync("ScrollDownBtn", null);
    }
c#
webview
uwp
asked on Stack Overflow Jul 31, 2017 by j.doe

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0