Link to home
Start Free TrialLog in
Avatar of frusti
frusti

asked on

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!
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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