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

onClick disable onMouseOut and make swap image default image

P: 3
On mouseover it goes to the correct map say TheMap1.jpg and then on mouseOut it defaults back to map, I need to do a onClick that sets the TheMap1.jpg mouseOver to the default TheMap.jpg so the TheMap1.jpg is now the default image not the TheMap.jpg. So after I click for information, and mouseOut of that area TheMap1.jpg will stay as all the MouseOuts Until I click another area of the map say TheMap10.jpg once clicked TheMap10.jpg will become the default image.

See code/ example of what I am doing http://www.wrighter.com/map

<SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript">
<!--
Expand|Select|Wrap|Line Numbers
  1.     if(document.images)
  2.     {
  3.       imagemap_TheMap = new Image();
  4.       imagemap_TheMap.src = '/wcss/images/TheMap.jpg';
  5.       imagemap_TheMap1 = new Image();
  6.       imagemap_TheMap1.src = '/wcss/images/TheMap1.jpg';
  7.       imagemap_TheMap2 = new Image();
  8.       imagemap_TheMap2.src = '/wcss/images/TheMap2.jpg';
  9.       imagemap_TheMap3 = new Image();
  10.       imagemap_TheMap3.src = '/wcss/images/TheMap3.jpg';;
  11.       imagemap_TheMap4 = new Image();
  12.       imagemap_TheMap4.src = '/wcss/images/TheMap4.jpg';
  13.       imagemap_TheMap5 = new Image();
  14.       imagemap_TheMap5.src = '/wcss/images/TheMap5.jpg';
  15.       imagemap_TheMap6 = new Image();
  16.       imagemap_TheMap6.src = '/wcss/images/TheMap6.jpg';
  17.       imagemap_TheMap7 = new Image();
  18.       imagemap_TheMap7.src = '/wcss/images/TheMap7.jpg';
  19.       imagemap_TheMap8 = new Image();
  20.       imagemap_TheMap8.src = '/wcss/images/TheMap8.jpg';
  21.       imagemap_TheMap9 = new Image();
  22.       imagemap_TheMap9.src = '/wcss/images/TheMap9.jpg';
  23.       imagemap_TheMap10 = new Image();
  24.       imagemap_TheMap10.src = '/wcss/images/TheMap10.jpg';
  25.       imagemap_TheMap11 = new Image();
  26.       imagemap_TheMap11.src = '/wcss/images/TheMap11.jpg';
  27.     }
  28.     function rollOver(iName,iState)
  29.     {
  30.       if(document.images)
  31.       {
  32.         document.images[iName].src = eval(iName + '_' + iState + '.src');
  33.       }
  34.     }
  35.  
// -->
</SCRIPT>
Oct 11 '06 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Just set the src of the image(s) onclick to the onmouseover image, e.g. onclick = "this.src = imageMap.src" or even call rollOver with the correct parameters. If all images need to be changed, use document.getElementsByTagName("img") to get all the images to loop over and set the src of each.
May 22 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.