Putting mouse coordinates in URL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Luongo
    New Member
    • Oct 2006
    • 22

    #1

    Putting mouse coordinates in URL

    Hi,

    I'm working on a project in which I'd like to have the user's mouse click coordinates included in a php URL which would load onClick, for example http://...imagecreate. php?x=200&y=100 . I've seen several scripts dealing with mouse coordinates, but can't seem to make things work with this. Can anyone help? Thanks...
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    See Mouse position during an event.

    Comment

    • hsriat
      Recognized Expert Top Contributor
      • Jan 2008
      • 1653

      #3
      But if you want to get the mouse coordinates when clicked on a particular image, use that image as input.

      ie.[html]<form action="target. php">
      <input type="image" src="/images/imageName.png" />
      </form>[/html]
      When clicked, your url will look like target.php?x=33 &y=21

      Where x and y are the coordinates where the user clicked on the image.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        If we're talking about a number of images, the form image element would have to be updated onclick. We would also need to work out the image position within the page for the offsets, though I think the OP wanted to load the new page onclick. Useful discussion all the same.

        Comment

        • hsriat
          Recognized Expert Top Contributor
          • Jan 2008
          • 1653

          #5
          Originally posted by acoder
          If we're talking about a number of images, the form image element would have to be updated onclick.
          Not really, we can give different names to different images.
          eg. if image name is "myimage", it will give parameters as myimage_x and myimage_y. I mean, it would suffix _x and _y to the image name when clicked, and submit the form.

          Originally posted by acoder
          We would also need to work out the image position within the page for the offsets, though I think the OP wanted to load the new page onclick.
          That's what we can think next, depending upon the exact needs of OP.

          Comment

          Working...