Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q326 How can I extract the X and Y coordinates from an image map, and use then to perform further processing in the current document?

irt.org | Knowledge Base | JavaScript | Image | Q326 [ previous next ]

Q326 How can I extract the X and Y coordinates from an image map, and use then to perform further processing in the current document?

AFAIK it is not possible to get the coords of a client side image map. If it were me I would use frames with one frame hidden and a server side image map. When the image is clicked load the document into the hidden frame, and then extract the x and y coordinates from the location and then pass them back to the visble frame for further processing:

top.html:

<frameset rows="100%,*">
<frame src="xyCoords.html" name="visibleframe">
<frame src="apage.html" name="hiddenframe">
</frameset>

xyCoords.html:

<script language="JavaScript"><!--
function next(x,y) {
    alert('x = ' + x + ' y = ' + y);
}
//--></script>

<a href="apage.html" target="hiddenframe"><img src="image.gif" width=200 height=100 border=0 ismap></a>

apage.html:

<script language="JavaScript"><!--
if (location.search.length > 0) {
    var str = location.search;
    var commaloc = str.indexOf(",");
    parent.visibleframe.next(str.substring(1, commaloc),str.substring(commaloc+1,str.length));
}
//--></script>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.