0

I have a web view (web window). In JavaScript, we have a function window.scrollTo(x,y). So the content will move to (x,y) position. But now I want to do a opposite thing: Assume that I have an anchor tag. When the content go to that tag. I want to know (x,y) moving position.

Can JavaScript do that?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
abelhoang
  • 271
  • 4
  • 14
  • possible duplicate of [Dynamically retrieve Html element (X,Y) position with JavaScript](http://stackoverflow.com/questions/442404/dynamically-retrieve-html-element-x-y-position-with-javascript) – epascarello May 17 '11 at 03:11
  • Possible duplicate of [Retrieve the position (X,Y) of an HTML element](https://stackoverflow.com/questions/442404/retrieve-the-position-x-y-of-an-html-element) – Alex McMillan Oct 02 '17 at 23:04

2 Answers2

0

jQuery has an offset method which gives you the (x, y) co-ordinates relative to the document - I hope this is what you're after.

http://api.jquery.com/offset/

Matty F
  • 3,763
  • 4
  • 30
  • 48
-1

in python we can do:

element=driver.find_element_by_xpath('YOUR PATH') 
print(element.location_once_scrolled_into_view)

this will print x and y positions

if you are using java you need search for something like "location_once_scrolled_into_view" in java

Kalamarico
  • 5,466
  • 22
  • 53
  • 70
romo
  • 33
  • 5
  • Looks like the question specifically asks about Javascript... what on Earth are you talking about with python and java ??? – Alex McMillan Oct 02 '17 at 23:03