Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

rollovers become inactive due to onclick event

Posted on 2003-11-27
9
Medium Priority
?
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…

609 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