Forum Moderators: open
I have an image and I want to get the coordinates where the user clicked without reloading the page.
I already solved this with an iFrame, but I'm _not_ happy with the iFrame!
index-file:
<a href="xx.html" target="ifrm"><img src="world.gif" ismap></a>
<iframe name="ifrm" id="ifrm" width="0" height="0" src="xx.html" border=0 frameborder=0></iframe>
Does anyone have another solution _without_ the iFrame?
(the page should not reload to get the coordinates)
Thank you very much in advance!
Best regards,
Hannes / Austria
<html>
<head>
<title>Image Map</title>
<script type="text/javascript">
<!-- Hide this code from non-JavaScript browsers
function Get(What) {
alert(What);
}
// End hiding -->
</script>
</head>
<body>
<img src="lion2.jpg" border=0 usemap="#mymap">
<map name=mymap>
<area shape="circle" coords="220,230,100" href="javascript:Get('head');">
<area shape="rect" coords="675,60,815,84" href="javascript:Get(1);">
<area shape="rect" coords="675,85,815,106" href="javascript:Get(2);">
<area shape="rect" coords="675,107,815,128" href="javascript:Get(3);">
<area shape="rect" coords="675,129,815,150" href="javascript:Get(4);">
<area shape="rect" coords="675,151,815,174" href="javascript:Get(5);">
<area shape="rect" coords="675,175,815,196" href="javascript:Get(6);">
<area shape="default" href="javascript:Get(0);">
</map>
</body>
</html>
Tedster, I also thought of trying to use the coordinates of the image and the mouse, but soon realized that is causing more troubles ... what if the user scrolls - I read that the coordinates of the image 'move' aswell, so I additionally need to check the coordinates of the scrolling...
Jalarie, my image is 720x360, so I would end up 259200 'area shapes'. Even if I make small rect's with 3x3pixels, there are 28800 'area shapes'.
Well, I think I will leave the page with the iframe - I included a note for users with non-iframe capable browser, that they need to enter the coordinates of their geographical location manually.
Thanks again!
All the best,
Hannes.
jalarie, actually the image is a map of the whole world, where the user can define his location, which is needed for the server-side calculation of Sun/Mars rise and set times :-)
But since the map only puts the value for longitude/latitude into a form and doesn't trigger the calculation, it is OK. The user can always enter longitude/latitude values manually into the form.
Thanks again,
Hannes.