1

我正在开发Windows 8.1的应用程序。我尝试了下面的代码,它不工作。如何禁用Windows 8.1中的WebView滚动

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

是否有任何JavaScript解决方案禁用触控,鼠标&键盘滚动?

+0

我很确定滚动是JS。网页如何加载以及你在加载什么内容?您可以使视图足够大,然后使用缩放变换来适应它。这正是我见过其他开发人员所做的,但也可能有其他方法。我正在使用手机,但稍后我会在计算机上放置演示。希望这有助于:)该webview是如此烦人的许多方面... –

+0

WebView的滚动条显示的Web浏览器实例,所以这就是为什么你无法控制他们从XAML。 – WiredPrairie

回答

2

我已经在给定的JS下面使用了我的需求。尽管我正在等待更好的(XAML)解决方案。

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

啊,用JavaScript来做。 –

+0

因为浏览器实际上只是Internet Explorer(包装)的一个实例,所以禁用它的最好方法就是使用CSS,就像您所做的那样。 – WiredPrairie

+0

我做了一个window.addEventListener('load',RemoveScrolling);并没有工作:( – ionescho

相关问题