How to disable WebView scrolling in Windows 8.1

2019-06-04 18:04发布

I am developing an app for Windows 8.1. I tried below code it's not working.

<WebView Source="http://wikipedia.org" 
    ScrollViewer.VerticalScrollBarVisibility="Disabled" 
    ScrollViewer.VerticalScrollMode="Disabled"/>

Is there any JavaScript solution to disable touch, mouse & key board scrolling?

1条回答
仙女界的扛把子
2楼-- · 2019-06-04 18:16

I have used below given JS for my requirement. Though I am waiting for a better (XAML) solution.

function RemoveScrolling() 
{
    var styleElement = document.createElement('style');
    var styleText = 'body, html { overflow: hidden; }'
    var headElements = document.getElementsByTagName('head');
    styleElement.type = 'text/css'; 
    if (headElements.length == 1) 
    { 
       headElements[0].appendChild(styleElement); 
    } 
    else if (document.head) 
    { 
        document.head.appendChild(styleElement); 
    } 
    if (styleElement.styleSheet) 
    { 
        styleElement.styleSheet.cssText = styleText; 
    } 
}
查看更多
登录 后发表回答