HighDots Forums  

An image map question

HTML Writing HTML for the Web (comp.infosystems.www.authoring.html)


Discuss An image map question in the HTML forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Christopher Benson-Manica
 
Posts: n/a

Default An image map question - 04-28-2004 , 09:54 AM






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.

Reply With Quote
  #2  
Old   
Raymond Loman
 
Posts: n/a

Default Re: An image map question - 04-29-2004 , 03:37 AM






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: raymond (AT) raymondloman (DOT) nl

Christopher Benson-Manica <ataru (AT) nospam (DOT) cyberspace.org> wrote

Quote:
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?

Reply With Quote
  #3  
Old   
Christopher Benson-Manica
 
Posts: n/a

Default Re: An image map question - 04-29-2004 , 08:32 AM



Raymond Loman <raymond (AT) raymondloman (DOT) nl> spoke thus:

Quote:
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.


Reply With Quote
  #4  
Old   
Raymond Loman
 
Posts: n/a

Default Re: An image map question - 05-03-2004 , 03:27 AM



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 <ataru (AT) nospam (DOT) cyberspace.org> wrote

Quote:
Raymond Loman <raymond (AT) raymondloman (DOT) 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.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.