Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » How do I scroll to the bottom of HTML in a browser control?(The vertical scroll bar is always null)
icon5.gif  How do I scroll to the bottom of HTML in a browser control? [message #660679] Mon, 21 March 2011 04:19 Go to next message
SBS  is currently offline SBS Friend
Messages: 57
Registered: January 2011
Member
I am trying to set the HTML for a browser control and then scroll to the bottom of the HTML but whenever I try to get the vertical scroll bar it is null.

This is how I am trying to scroll to the bottom:

		Display.getCurrent().asyncExec(new Runnable() {

			@Override
			public void run() {
				final ScrollBar vsb = browser.getVerticalBar();
				if (vsb != null) {
					vsb.setSelection(vsb.getMaximum());
				}
			}
		});



but vsb is always null even when I can see content in the browser that spans more than one page and a vertical scroll bar is visible.

How do I do what I am trying to achieve?
Re: How do I scroll to the bottom of HTML in a browser control? [message #661169 is a reply to message #660679] Wed, 23 March 2011 12:46 Go to previous messageGo to next message
Lakshmi ShanmugamFriend
Messages: 276
Registered: July 2009
Location: India
Senior Member
Hi,
SWT doesn't create the scrollbars for the Browser. Hence, Browser.getVerticalScrollBar()/getHorizontalScrollBar doesn't return the Browser's scrollbars.


Lakshmi P Shanmugam
Re: How do I scroll to the bottom of HTML in a browser control? [message #661587 is a reply to message #660679] Fri, 25 March 2011 13:53 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
If you're showing HTML content then you can do something like:

browser.execute("window.scrollTo(0, document.body.scrollHeight)");

Grant


"SBS" <jturnbul@uow.edu.au> wrote in message
news:im6j7h$q9o$1@news.eclipse.org...
>I am trying to set the HTML for a browser control and then scroll to the
>bottom of the HTML but whenever I try to get the vertical scroll bar it is
>null.
>
> This is how I am trying to scroll to the bottom:
>
> Display.getCurrent().asyncExec(new Runnable() {
>
> @Override
> public void run() {
> final ScrollBar vsb = browser.getVerticalBar();
> if (vsb != null) {
> vsb.setSelection(vsb.getMaximum());
> }
> }
> });
>
>
>
> but vsb is always null even when I can see content in the browser that
> spans more than one page and a vertical scroll bar is visible.
>
> How do I do what I am trying to achieve?
Previous Topic:Canvas with overlaid buttons speed problem
Next Topic:adding a button to a composite at position x
Goto Forum:
  


Current Time: Sun Mar 29 07:14:00 GMT 2020

Powered by FUDForum. Page generated in 0.01686 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top