Reputation: 115
I can move to certain location of the page by using:
HTMLDocument doc2 = (HTMLDocument)webBrowser1.Document;
int offSetTop = 1000;
doc2.parentWindow.scrollTo(0, offSetTop );
The screen automatically scroll to point(0,offSetTop) of the page. But if I scroll manually to that position of page, how can I get the offSetTop value if there is no element tag there ?
Upvotes: 1
Views: 719
Reputation: 10153
You can get offSetTop
,current position of page with scrollTop
attribute:try this code
HTMLDocument doc2;
private void wb_LoadCompleted(object sender, NavigationEventArgs e)
{
doc2 = (HTMLDocument)wb.Document;
}
private void GetCurrentpositionOfPage_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show( doc2.parentWindow.document.body.getAttribute("scrollTop").ToString());
}
Upvotes: 2