Solved

rollovers become inactive due to onclick event

Posted on 2003-11-27
9
251 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
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…

910 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now