0

Is there a way to get the coordinates(x,y) of the URL on a website in the browser window?

I already tried to view the inspect element but was not able to find what I am looking for.

AlphaWolf
  • 395
  • 2
  • 7
  • 16
  • what is your question? – joel goldstick Sep 04 '16 at 13:03
  • I mean to get the coordinate(x,y) of a link in the browser's window; @@!sorry for bad English, i have edited the question. – AlphaWolf Sep 04 '16 at 13:07
  • python is server side, so it can't help you. Javascript in the browser might be the way to go. You should tag question with javascript – joel goldstick Sep 04 '16 at 13:10
  • any solution in popular programming language are welcome :) – AlphaWolf Sep 04 '16 at 13:11
  • What is the Java tag doing on your post? Do you think this has anything to do with Java? If not, delete the tag. What is the Python tag doing on your post? Do you think this has anything to do Python? If not, delete the tag. – jwpfox Sep 04 '16 at 13:12
  • 1
    Welcome to SO. Please visit the [help] to see what and how to ask. HINT: Post effort and code and in this case elaborate on WHAT you need to do. Why do you need the coordinates? Is it your own site? Are you trying to implement click fraud on Google ads? – mplungjan Sep 04 '16 at 13:14
  • Thank you, i am really do not know python and java can't do that so i tagged them in.Editted. – AlphaWolf Sep 04 '16 at 13:15
  • @mplungjan of course not, that is cheat bad behavior. – AlphaWolf Sep 04 '16 at 13:16
  • How should we know? Not enough information from you – mplungjan Sep 04 '16 at 13:18
  • 1
    Possible duplicate of [Retrieve the position (X,Y) of an HTML element](http://stackoverflow.com/questions/442404/retrieve-the-position-x-y-of-an-html-element) – JJJ Sep 04 '16 at 13:19

1 Answers1

0

I think I understand what you're asking for. In this case I have identified the link when it is clicked and by ID. The former will execute the link behavior, but both methods do what you want. Note that this only gives you the location within the browser's content and not the absolute location on the screen.

<p>I put some text here for the experience of having <a id="link" href="somewhere.com" onclick="findMe(this)">this link</a> in a paragraph which will put it on the page and I can adjust the size of the browser window to show that it moves around and changes the location.</p>
<p><button onclick="findTag()">Click</button>
<script>
  function findMe(tag)
  {
    alert(tag.offsetLeft+", "+tag.offsetTop);
  }

  function findTag()
  {
    //so this would identify the <a> without following the href
    findMe(document.getElementById("link"));
  }
</script>
BSD
  • 329
  • 3
  • 13