I am working on a project in Java.
In this project, I have to find absolute position of an element of DOM. But I don't know how to do this.
I searched on net, I found the same for Javascript. I found this from here.
Code is this,
function getPosition(element) {
var xPosition = 0;
var yPosition = 0;
while(element) {
xPosition += (element.offsetLeft - element.scrollLeft + element.clientLeft);
yPosition += (element.offsetTop - element.scrollTop + element.clientTop);
element = element.offsetParent;
}
return { x: xPosition, y: yPosition };
}
When I try to write this code in Java, offsetLeft, offsetTop variable is not found. Can you tell me, how can I write this code in Java?
Edit No. 1
Is there any method using Jsoup for the same?