How to retrieve the scrollbar position of the webbrowser control in .NET

前端 未结 7 1826
刺人心
刺人心 2020-12-11 18:44

I tried using webBrowser1.Document.Body.ScrollTop and webBrowser1.Document.Body.ScrollLeft, but they don\'t work. They always return 0 and I can\'t

7条回答
  •  难免孤独
    2020-12-11 19:23

    For anyone interested, here's the C# code equivalent to Marc's answer:

    System.Windows.Forms.HtmlDocument htmlDoc = webBrowser.Document;
    if (htmlDoc != null)
    {
        int scrollTop = htmlDoc.GetElementsByTagName("HTML")[0].ScrollTop;
        int scrollLeft = htmlDoc.GetElementsByTagName("HTML")[0].ScrollLeft;
    }
    

提交回复
热议问题