Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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?

You are here: irt.org | FAQ | JavaScript | Image | Q326 [ previous next ]

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>

©2018 Martin Webb