Solved

rollovers become inactive due to onclick event

Posted on 2003-11-27
9
252 Views
Last Modified: 2006-11-17
Here is what I have. The problem is that when a user clicks on an area of the map, http://eyecreate.ods.org:8000/atx/asia.html

the rollovers stop working rather than the clicked image becoming the default image.
I think the problem is with the keepPic function but I am not sure how to solve it.


   //world map
preload('fareast','images/maps/fareast.gif')
preload('china','images/maps/china.gif')
preload('hongkong','images/maps/hongkong.gif')
preload('japan','images/maps/japan.gif')
preload('korea','images/maps/korea.gif')
preload('philippines','images/maps/philippines.gif')
preload('singapore','images/maps/singapore.gif')
preload('thailand','images/maps/thailand.gif')
        
function swapImg(layer,imgName,imgObj) {
          o = (n && layer?document.layers[layer].document.images[imgName]:document.images[imgName]);
          if(!o.hasswapped) o.src = eval(imgObj+".src");
       }

       var oRef = null;
       var oRefImg = null;
function keepPic(layer,imgName,imgObj) {
       if (document.images) {
       o = (n && layer?document.layers[layer].document.images[imgName]:document.images[imgName]);
       if(o) {
       oRef = o
       oRefImg = o.src;
       o.src = eval(imgObj+".src");
       o.hasswapped = true;
       }
      }
     }      


<a href="javascript:void(0);" onClick="keepPic('asia','orient','china');" onMouseOver="swapImg('asia','orient','china');" onMouseOut="swapImg('asia','orient','fareast');" class="maplink">China</a>


cheers and thanks in advance for your help.
Frankenstrat
0
Comment
Question by:frankenstrat
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 5

Expert Comment

by:ho_alan
ID: 9834746
<a href="javascript:void(0);" onClick="keepPic('asia','orient','china');return true;" onMouseOver="swapImg('asia','orient','china'); return false;" onMouseOut="swapImg('asia','orient','fareast');return false;" class="maplink">China</a>

see if it helps

<a href="javascript:keepPic('asia','orient','china');return true;"  onMouseOver="swapImg('asia','orient','china'); return false;" onMouseOut="swapImg('asia','orient','fareast');return false;" class="maplink">China</a>
0
 

Author Comment

by:frankenstrat
ID: 9834773
That solved the problem of the images continuing to rollover as they should but I want the keepPic function to retain the image in its rollover state while keeping the rollover available for the other areas of the image.

Cheers
Frankenstrat
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 9835544
<a href="#" onClick="keepPic('asia','orient','china');return false"  
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 250 total points
ID: 9835552
You cannot have href="something; return true"
it even tells you "return outside function" in the error message
0
 
LVL 5

Expert Comment

by:ho_alan
ID: 9835555
yes, thanks :-)
0
 

Author Comment

by:frankenstrat
ID: 9837621
<a href="#" onClick="keepPic('asia','orient','china');return false" didn't work either. I prefer not to use the # because it causes the page to jump when a user clicks on the image.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 9839197
It should not when there is areturn false in the onclick
0
 
LVL 16

Expert Comment

by:jaysolomon
ID: 10383964
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: mplungjan {http:#9835552}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jAy
EE Cleanup Volunteer
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question