0

I've created a web view recently & everything seems to be working fine except the window.scroll event. I'm loading content in my mobile website once user reaches the end of the screen, unfortunately that doesn't work in Android Webview.

I've enabled javascript in Android Webview.

Here is the simple code I'm using in PHP:

$(window).scroll(function(){
  alert('H'); //This never happens
});

In main_activity.java, this line is included:

webSettings.setJavaScriptEnabled(true);

What could be the possible reason behind this? Any solution?

Kailas
  • 7,350
  • 3
  • 47
  • 63
Guy in the chair
  • 1,045
  • 1
  • 13
  • 42

1 Answers1

0

make sure jQuery loaded finish, then your code can work fine
put the code after </html> :

<script type="text/javascript">
        window.onload = function() {
            if (window.jQuery) {  
                // jQuery is loaded  
                alert("Yeah!");
            } else {
                // jQuery is not loaded
                alert("Doesn't Work");
            }
        }       
</script>

if alert "Yeah!", just replace alert("Yeah!") to your code.

HenryChuang
  • 1,449
  • 17
  • 28