Solved

rollovers become inactive due to onclick event

Posted on 2003-11-27
9
255 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

717 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