Question

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 ?

Was it helpful?

Solution

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());
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top