Skip to main content



      Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Auto scroll contents of SWT Browser(How can I automatically scroll down the contents of a Bowser?)
icon9.gif  Auto scroll contents of SWT Browser [message #549760] Tue, 27 July 2010 16:44 Go to next message
Eclipse UserFriend
Hello,

I am creating an application that requires an HTML report to be generated. I am using a SWT Browser to display the report and I need to auto scroll down as the report is filled.

I know that using getVerticalBar() will not work because the browser is nothing more than a embedded IE using OLE.

Is there any way to do this?

Thanks a lot,
Milton.
Re: Auto scroll contents of SWT Browser [message #549769 is a reply to message #549760] Tue, 27 July 2010 17:40 Go to previous messageGo to next message
Eclipse UserFriend
I was just working on a project that did this. Actually the Browser widget in RAP is just an iframe, but this should work equally well on SWT desktop version where it is using an embedded IE or Mozilla browser.

All I did is add a LocationListener to the Browser before calling setText() or setURL(). It executes a simple javascript call to scroll the browser to the bottom.

         browser.addLocationListener(new LocationAdapter()
         {
            public void changed(LocationEvent event)
            {
               browser.execute("window.scrollTo(0, document.body.scrollHeight)");
            }
         });

Re: Auto scroll contents of SWT Browser [message #549874 is a reply to message #549769] Wed, 28 July 2010 06:05 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

you should also be able to work with anchors in case you don't know
where to scroll the page exactly. Setting "foo.html#myanchor" as URL for
the Browser widget should do the trick.

Regards,
Ben

Cole Markham wrote:
> I was just working on a project that did this. Actually the Browser
> widget in RAP is just an iframe, but this should work equally well on
> SWT desktop version where it is using an embedded IE or Mozilla browser.
>
> All I did is add a LocationListener to the Browser before calling
> setText() or setURL(). It executes a simple javascript call to scroll
> the browser to the bottom.
>
>
> browser.addLocationListener(new LocationAdapter()
> {
> public void changed(LocationEvent event)
> {
> browser.execute("window.scrollTo(0,
> document.body.scrollHeight)");
> }
> });
>
>


--
Benjamin Muskalla | EclipseSource Karlsruhe
Need professional support for RAP and RCP?
Go to: http://eclipsesource.com/support
Twitter : @bmuskalla
Blog : http://eclipsesource.com/blogs/tag/rap/
icon14.gif  Re: Auto scroll contents of SWT Browser [message #549927 is a reply to message #549760] Wed, 28 July 2010 09:44 Go to previous message
Eclipse UserFriend
Cole, thanks a lot for your reply that worked! I never payed attention to the execute method...

Benjamin thanks for your reply, but in my case I just need to scroll to the end of the HTML, I think I can't use anchors because the HTML I am displaying is not saved in a file as it is generated, I just use setText()

Thank you very much!
Previous Topic:Junit 4 support
Next Topic:DND feedback and effects
Goto Forum:
  


Current Time: Sat Mar 22 22:29:34 EDT 2025

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

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

Back to the top