How to scroll / set scrollbar position programatically?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

How to scroll / set scrollbar position programatically?

Postby AndyB » Tue May 23, 2017 4:30 pm

I want to scroll a page by code.
My first attempt was to use SendMouseWheelEvent, but this stops working at some point after navigation, click on buttons, select item in dropdown....
I use now window.scrollBy() in javascript. This generally works fine, but it does not work with all pages. The page it works not uses bootstrap.js, don't know if that's the reason.
The scrollbar is displayed and i can manually scroll, but window.scrollBy() has no effect, SendMouseWheelEvent also does not work.
The scrollBy function does not work in IE either with this site, also not window.scrollTo().

Is there another way in CEF to scroll a page?
AndyB
Techie
 
Posts: 39
Joined: Sun Apr 16, 2017 3:00 pm

Re: How to scroll / set scrollbar position programatically?

Postby Czarek » Thu May 25, 2017 12:59 pm

Check if window.scrollBy is a native function or whether it was overwritten. Maybe the page uses a custom scrolling mechanism and in such case you would have to figure out what library func to call.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: How to scroll / set scrollbar position programatically?

Postby AndyB » Sat May 27, 2017 2:41 pm

Thank you for the hint. The site is down since some days, i check this when it is up again...
AndyB
Techie
 
Posts: 39
Joined: Sun Apr 16, 2017 3:00 pm

Re: How to scroll / set scrollbar position programatically?

Postby AndyB » Mon May 29, 2017 11:37 am

The website with this "strange" behavior is https://www13.state.nj.us/DataMiner
When i execute "alert(window.scrollBy);" then "function scrollBy() { [native code] }" gets displayed.
As far i can see scrollBy is not overwritten.
The window.scrollBy has no effect in IE, Firefox, Chrome.
However, touch scroll works in IE browser control and CefSharp WinForm control.
I think there must be a non-javascript method to scroll a page, but no idea now where to look further.
AndyB
Techie
 
Posts: 39
Joined: Sun Apr 16, 2017 3:00 pm

Re: How to scroll / set scrollbar position programatically?

Postby amaitland » Wed May 31, 2017 6:05 pm

What does your SendMouseWheelEvent code look like?

It's a pretty widely used piece of code, so if there is a reproducible bug it should be fixed.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: How to scroll / set scrollbar position programatically?

Postby AndyB » Thu Jun 01, 2017 5:00 pm

amaitland, please see my feature request "add scroll function"
AndyB
Techie
 
Posts: 39
Joined: Sun Apr 16, 2017 3:00 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 38 guests