Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 338
  • Last Modified:

Dynamic Usemap with Javascript

I have a very large Image and have direction-buttons to navigate over them (with arrays). To change the Image is no problem, but how can I change the map? I have just make the HTML-Side with document.write, but now, I become an error when I`m clicking on one direction-button (JavaScript Error: incorrect number of arguments). Have any an idee? Thanks!
0
frusti
Asked:
frusti
  • 2
1 Solution
 
Michel PlungjanIT ExpertCommented:
1. To change the actual areas you will need to use transparent layers and DHTML, with somewhat limited browser support.
An IMHO  better way is to have an array of hrefs.

I will continue in a comment.
0
 
Michel PlungjanIT ExpertCommented:
If you map all the possible hrefs, you can swap hrefs onmouseover or onclick somewhere else:
<SCRIPT>
/* The array below can be made 1.0 compatible if needed */
theMaps = new Array()
theMaps[0] = new Array('page1.html',null,null);
theMaps[1] = new Array(null,'page2.html',null);
theMaps[2] = new Array(null,null,'page3.html');

CurrentMap = 0;

function goThere(idx) {
   theHref = theMaps[CurrentMap][idx];
   if (theHref != null) location = theHref;
}
fucntion myVoid() { ; } // nothing
</SCRIPT>
<A HREF="javascript:myVoid()" onClick:CurrentMap=0;"><IMG...></A>
<A HREF="javascript:myVoid()" onClick:CurrentMap=1;"><IMG...></A>
<A HREF="javascript:myVoid()" onClick:CurrentMap=2;"><IMG...></A>
<MAP>
<AREA.... HREF="javascript:goThere(0);>
<AREA.... HREF="javascript:goThere(1);>
<AREA.... HREF="javascript:goThere(2);>
</MAP>

So the click in the href will change the links in the map.

Hope I made myself clear,

Michel
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now