getting absolute position of HTML element in webbrowser control with C#

后端 未结 7 1270
萌比男神i
萌比男神i 2021-02-04 07:39

I was wondering if its possible to get the absolute position of specific HTML element I have loaded in webbrowser control with C#.

I tried almost all of the options that

7条回答
  •  你的背包
    2021-02-04 08:04

    Not sure why but offsetparent is not allways returned (case of IE11, map object) I had to add parentElement in the loop when parentOffset is not provided

        While parent IsNot Nothing
                y += parent.offsetTop
                x += parent.offsetLeft
                If  parent.offsetParent IsNot Nothing Then
                    parent = parent.offsetParent  
                Else
                    parent = parent.parentElement
                End If
        End While
    

    And you need to add IE browser position, the menu space and borders ...

提交回复
热议问题