Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 20:44 Go to next message
Milton  is currently offline Milton Friend
Messages: 10
Registered: October 2009
Junior Member
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 21:40 Go to previous messageGo to next message
Cole Markham is currently offline Cole MarkhamFriend
Messages: 150
Registered: July 2009
Location: College Station, TX
Senior Member

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 10:05 Go to previous messageGo to next message
Benjamin Muskalla is currently offline Benjamin MuskallaFriend
Messages: 338
Registered: July 2009
Senior Member
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 13:44 Go to previous message
Milton  is currently offline Milton Friend
Messages: 10
Registered: October 2009
Junior Member
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: Mon Apr 22 23:42:18 GMT 2024

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

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

Back to the top