467,163 Members | 944 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,163 developers. It's quick & easy.

An image map question

Here's my situation: I have four image maps in a certain document.
They're exactly the same, except that different javascript arguments
are passed to a function when they're clicked:

<img name="myimg" src="/images/myimg.jpg" usemap="#mapA" />
<map name="mapA">
<area shape="rect" coords="0,0,20,15" href="javascript:f(0)" />
<!-- ... -->
</map>
<img name="myimg" src="/images/myimg.jpg" usemap="#mapB" />
<map name="mapB">
<area shape="rect" coords="0,0,20,15" href="javascript:f(1)" />
<!-- ... -->
</map>

And so on. My question: Is there a way to use only one image map for
the four images here and still get the appropriate script calls?

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 20 '05 #1
  • viewed: 2594
Share:
3 Replies
Hoi Christopher,

Why not use just the <img>-tag with javascript: onClick like this:
<img name="myImg1" src="/images/myimg.jpg" onClick="f(this)";>

In function f you use

function f(image)
{
var myName=image.name();

}

depending on the content of myName you take appropriate action(s).

Hope this helps,

Raymond Loman
i: http://www.raymondloman.nl
e: ra*****@raymondloman.nl

Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote in message news:<c6**********@chessie.cirr.com>...
Here's my situation: I have four image maps in a certain document.
They're exactly the same, except that different javascript arguments
are passed to a function when they're clicked:

<img name="myimg" src="/images/myimg.jpg" usemap="#mapA" />
<map name="mapA">
<area shape="rect" coords="0,0,20,15" href="javascript:f(0)" />
<!-- ... -->
</map>
<img name="myimg" src="/images/myimg.jpg" usemap="#mapB" />
<map name="mapB">
<area shape="rect" coords="0,0,20,15" href="javascript:f(1)" />
<!-- ... -->
</map>

And so on. My question: Is there a way to use only one image map for
the four images here and still get the appropriate script calls?

Jul 20 '05 #2
Raymond Loman <ra*****@raymondloman.nl> spoke thus:
Why not use just the <img>-tag with javascript: onClick like this:
<img name="myImg1" src="/images/myimg.jpg" onClick="f(this)";>


Well, that'd be fine, except that the image is actually a map, so
using the img.onClick attribute doesn't help me much unless I break
the image map into its component images.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 20 '05 #3
Christopher,

You got me! Probably you can use the ID-attribute within the <area>-tag
to get to know in your function (f) where you came from?
<area id="first" coords="..." href="javascript:f(this(or this.id));">

Good luck. Let me know ... ;-)

Raymond
Christopher Benson-Manica <at***@nospam.cyberspace.org> wrote in message news:<c6**********@chessie.cirr.com>...
Raymond Loman <ra*****@raymondloman.nl> spoke thus:
Why not use just the <img>-tag with javascript: onClick like this:
<img name="myImg1" src="/images/myimg.jpg" onClick="f(this)";>


Well, that'd be fine, except that the image is actually a map, so
using the img.onClick attribute doesn't help me much unless I break
the image map into its component images.

Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Ralph Freshour | last post: by
reply views Thread by Vlado | last post: by
10 posts views Thread by Fred Nelson | last post: by
11 posts views Thread by KarimL | last post: by
68 posts views Thread by Nak | last post: by
35 posts views Thread by Stan Sainte-Rose | last post: by
12 posts views Thread by Lance | last post: by
4 posts views Thread by LT.Ang | last post: by
6 posts views Thread by David Stone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.