-
Oct 11th, 2013, 09:22 AM
#1
Thread Starter
Hyperactive Member
WebBowser scrolling
Can i use buttons to scroll up and down a web page instead of using the scroll bars from the web browser control. If so, how? Does anyone know the codes to do it?
-
Oct 11th, 2013, 10:07 AM
#2
Re: WebBowser scrolling
Sure, the issue is that this method doesn't work %100 of the time. First you turn Option Strict and Explicit On:
Code:
Option Strict On
Option Explicit On
Public Class Form1
End Class
Then add your two buttons to the form.
Then generate the click events for each button:
Code:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'Up
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
'Down
End Sub
For the scroll up and down, you set the webbrowser's document's body's scrolltop property. To scroll left to right, you set the Body's scroll left property. Here is the code for the up and down scrolling:
Code:
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
'Up
WebBrowser1.Document.Body.ScrollTop -= 1
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
'Down
WebBrowser1.Document.Body.ScrollTop += 1
End Sub
But like I said, that won't work %100 of the time. A sure fire method that should work is the WebBrowser.Document.Window.ScrollTo method. The issue with this is that you scroll to a specific point, instead of scrolling up or down by x amount.
-
Oct 12th, 2013, 09:57 AM
#3
Thread Starter
Hyperactive Member
Re: WebBowser scrolling
Originally Posted by dday9
Sure, the issue is that this method doesn't work %100 of the time. First you turn Option Strict and Explicit On:
But like I said, that won't work %100 of the time. A sure fire method that should work is the WebBrowser.Document.Window.ScrollTo method. The issue with this is that you scroll to a specific point, instead of scrolling up or down by x amount.
Thanks Dday, is there a way to scroll only 3 or four lines at a time using your last method?
-
Oct 12th, 2013, 12:34 PM
#4
Addicted Member
Re: WebBowser scrolling
This brings up a great feature that should be added to firefox/chrome etc. You know how when you refresh a page...while reading an article... it will take you back to your last position?
That seems as if there is something in the code specifying your 'location' on the page. So why not have a feature that allows you to automatically skip to your favorite position...say the celebrity/entertainment area on news.google.com.. everytime you load it
I suppose there could also be a plugin...where you could hit buttons for certain websites... for like Google News that say like [tech] [top stories] [sports] etc. Instead of wasting 5 seconds scrolling to the correct position or having to click a link that will load ONLY those stories etc.
Sorry thought it was a good idea....didn't mean to rain on your post with non-relevant information <3
dim jenn as geek = true
Learning ~ Visual Basic 2010 ~ in free time between college/work -
currently looking for a 'programming buddy' / 'coder friend' / and or 'mentor'. p.m. me if you
have ANY free time AT ALL I'm like 33% of a novice level ~ willing 2 listen/learn +
i am totally super motivated & promise to make an effffin amazing protege!!! #swag
| -_-_- -_-_- |
...W.T..F!?.....
||| Matter on the atomic/quantum level isn't solid or even matter at all. It can also exist in at least 2 places simultaneously (demonstrated in lab). It's position can only be established when it's actually observed. If we turn our back on it... it goes back to a wave form. History show's that every previous generation (since the beginning of time) got almost everything wrong. Then it might very well stand to reason that up is down & right can be wrong. Admit it.. our combined perception of reality is just that, we know absolutely nothing of actual reality & to think we do is simply subscribing to a "ignorance is bliss" mantra |||
-
Oct 31st, 2013, 12:20 PM
#5
Junior Member
Re: WebBowser scrolling
I think she^ has a good idea. Would it be possible to get the location of were you were last at on the webpage when you refreshed. Say you were on a web page that had 1000's of words on it and you highlighted one word and clicked a button and then left the page then when you came back to that page and clicked a button it would re-highlight that word and scroll the web browser to that word. Would that be the slightest bit possible?
-
Oct 31st, 2013, 12:35 PM
#6
Re: WebBowser scrolling
@Richard, start you own thread. This prevents cluttering of existing threads.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|