How to disable WebView scrolling in Windows 8.1

╄→尐↘猪︶ㄣ 提交于 2019-12-08 07:40:44

问题


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:


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; 
    } 
}


来源:https://stackoverflow.com/questions/20103527/how-to-disable-webview-scrolling-in-windows-8-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!