Greetings I saw the application for viewing the site in webView, a task appeared when you open a program to scroll the page to a specific element. webView.scrollTo () takes absolute values ​​for the parameters, is it possible to somehow get the position of the element (even if you load the html-code) or to implement a scroll in some way?

  • Element arbitrary? Is there a similar tag-link in the vicinity: <a name="anchor"></a> , which you can go to by adding to the page address #anchor - woesss
  • Element one is the search string on the site, but I don’t have any idea how to access it (to its name) from the application - Drive Falcon
  • Hmm ... usually the search is at the top and you don’t need to turn to it. Can you give this piece of page code or its address? On a pinch, you can try to insert such an anchor with a script and then go to it. - woesss
  • Script anchor - directly to the page? I give an example: this page in webView has title, question, firstComment - how to programmatically make a scroll before firstComment? (very conditional) - Drive Falcon
  • Very conditionally something like this: webView.loadUrl("javascript:document.getElementById('firstComment').scrollIntoView();"); - run after loading the desired page. - woesss

1 answer 1

upd after a couple of weeks: webView.loadUrl ("javascript: document.getElementById ('firstComment'). scrollIntoView ();") method; works fine if you paste in the right place (in my case I placed the webViewClient object in onPageFinished).