Disable scrolling in a WebView?

You must Login before you can answer or comment on any questions.

Is there a way to disable scrolling within a webView? reason being I have a webview in a scrollView (along with other elements above and below the webview) and I want the webView to be static and not scroll as I already have the scrollView that is taking care of that.

Any help would be much appreciated.

— asked 2 years ago by Coop Lp
0 Comments

3 Answers

This is working for me:

<head>
<script type="text/javascript">
//Don't allow the webView to scroll, but still let it be clickable
    document.addEventListener("touchmove", function(e){
        e.preventDefault();
        return false;
    }, false);
</script>
</head>

Have you tried disabling touch on the webview via the touchEnabled property?

— answered 2 years ago by Tony Lukasavage
answer permalink
2 Comments
  • I ended up using the following code:

    webView.addEventListener("touchmove", function(e)
    {
        e.preventDefault();
    });
    It disables the scroll but think it also disables any interaction with the webView... which isn't ideal but for what I need it for it will do. But if anyone has any other options would love to hear them.

    Cheers

    — commented 2 years ago by Coop Lp

  • I'm looking for the same thing. The webView needs to handle "click" events but I want to hide the scrollbars and zoomcontrols. Guessing that's what you need aswell.

    Tried to use your above suggestion but it doesn't seem to work. Getting error "Cannot call property preventDefault" on the webView. You didn't it seems. Did you do anything to get that running?

    — commented 2 years ago by Mattias Lundström

Your Answer

Think you can help? Login to answer this question!