By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,676 Members | 1,759 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,676 IT Pros & Developers. It's quick & easy.

An image map question

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.