473,326 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

x,y of an image

HI I am working on a project which is used to find the shortest path
between two location on the map of my city, so when I click on the map
I get the x,y coordinate of the whole page not of the image by using
event.x , event.y . But I need a function that maybe use the image as a
parameter to get the x,y of this image.

Shameram Sadaki
thanx in advance

Mar 22 '06 #1
1 1372

ch******@hotmail.com wrote:
HI I am working on a project which is used to find the shortest path
between two location on the map of my city, so when I click on the map
I get the x,y coordinate of the whole page not of the image by using
event.x , event.y . But I need a function that maybe use the image as a
parameter to get the x,y of this image.

Shameram Sadaki
thanx in advance


The point is that your image is placed in another element (so-called
"offsetParent"), that is itself placed in another one and so on. I can
not see your code but I can suppose it looks like:
<table>
<tr>
<td>
<img ....

First of all I should recommend you to use clientX and clientY instead
of x and y (x,y works only in IE). Then you have to calculate total
offset and adjust primary values of x, y coordimates.
Example:
<html>
<head>
<script type="text/javascript">
function MouseClick(sender, e)
{
//total offset for X-axis
var deltaX = 0;
//total offset for Y-axis
var deltaY = 0;

var elem = sender;
while(elem!=null && elem.offsetLeft!=null && elem.offsetTop!=null)
{
deltaX+=elem.offsetLeft;
deltaY+=elem.offsetTop;
elem = elem.offsetParent;
}

//relative coordinates
var imageX = e.clientX - deltaX;
var imageY = e.clientY - deltaY;

alert("clientX=" + e.clientX +";clientY="+ e.clientY + ";imageX=" +
imageX +";imageY="+ imageY);
}
</script>
</head>
<body>
<table width="100%" height="100%">
<tr>
<td align="center" valign="middle">
<img onclick="MouseClick(this, event);"
src="10_69.jpg"/>
</td>
</tr>
</table>
</body>
</html>

Mar 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Pierre Tremblay | last post by:
Hi! I am trying to display an image in my html document. The document contains the following line: <td class="Input"><img...
3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
8
by: Jef Driesen | last post by:
I'm implementing some image processing algorithms in C++. I created a class called 'image' (see declaration below), that will take care of the memory allocations and some basic (mathematical)...
6
by: QuasiChameleon | last post by:
Hi, I'm trying to create a grayscale image class that reads and writes grayscale Targa format. This works well with smaller images, but corrupts larger images and creates a "Segmentation fault...
15
by: Anand Ganesh | last post by:
HI All, I have an Image. I want to clip a portion of it and copy to another image. How to do this? I know the bounding rectangle to clip. Any suggestions please. Thanks for your time and...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
6
by: comp.lang.php | last post by:
/** * Generate the random security image * * @access public * @param $willUseFilePath (default false) boolean to determine if you will be using a file path * @param mixed $filePath (optional)...
1
by: bharathv6 | last post by:
i need to do is modify the image in memory like resizing the image in memory etc ... with out saving it disk as i have to return back the image with out saving it disk PIL supports the use of...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.