WebView jump to anchor using loadDataWithBaseUrl

后端 未结 5 1326
名媛妹妹
名媛妹妹 2021-01-02 10:25

My Android app uses a WebView to display a bunch of HTML code that I generate \'on the fly\'. The HTML code is loaded using the following code:



        
5条回答
  •  执笔经年
    2021-01-02 11:18

    If you have external action (eg: onclick event), try this code

     public static void scrollToAnchor(String id) {
            sWebView.loadUrl("javascript:document.getElementById(\"" + id + "\").scrollIntoView()");
     }
    

提交回复
热议问题