Solved

rollovers become inactive due to onclick event

Posted on 2003-11-27
9
250 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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…

707 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

16 Experts available now in Live!

Get 1:1 Help Now