This discussion is archived
2 Replies Latest reply: May 8, 2012 12:26 PM by 935688 RSS

How to scroll webview Programally  ?

935688 Newbie
Currently Being Moderated
How to scroll webview programally ?
  • 1. Re: How to scroll webview Programally  ?
    jsmith Guru
    Currently Being Moderated
    Use the JavaScript scrollTo function.

    Either execute the JavaScript in response to (for example) an html button onclick event (as shown on the linked page)
    http://www.w3schools.com/jsref/met_win_scrollto.asp

    or execute the JavaScript using the WebEngine.executeScript() method.
  • 2. Re: How to scroll webview Programally  ?
    935688 Newbie
    Currently Being Moderated
    Thank you for very quick reply !!

    WebView has no method (JViewport.setViewPosition or JComponent.scrollRectToVisible).
    So, I have no idea ...........
    execute the JavaScript using the WebEngine.executeScript() method.
    That's great!

    I try this
    ---------------------------------------
    WebEngine egg;
    egg.executeScript("window.scrollTo(455,0); ");
    ------------------------------
    this code works well. :-)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points