Results 1 to 3 of 3

Thread: JScript : Getting img X & Y

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212

    JScript : Getting img X & Y

    I've got an image, which act as a map and i need to find the coordinate relative to the img when user click on it.
    I've successfully manage to get the document coord (x & y) but can't get the img coord, any idea ?

    Code:
    		
    function GetCoord(e)
    		{
    			var x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
    			var y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
    			x = x - document.frmAjout.imgCarte.scrollLeft;
    			y = y - document.frmAjout.imgCarte.scrollTop;
    			document.frmAjout.txtCoordX.value = x;
    			document.frmAjout.txtCoordY.value = y;
    		}
    Regards,

    El-Nino

  2. #2

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2000
    Location
    Québec, Canada
    Posts
    212
    Those scripts don't seem to work
    I can get the screen x,y
    But i'd like to be able to get the x&y relatibve to the images without submitting the form...
    Like x = x - img.left
    y = y - img.top

    Then i got the img x & y


    Thanks for the reply
    Regards,

    El-Nino

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width