View Single Post
Old 05-11-2009, 09:51 PM   PM User | #1
Vetir39
New to the CF scene

 
Join Date: May 2009
Posts: 6
Thanks: 1
Thanked 0 Times in 0 Posts
Vetir39 is an unknown quantity at this point
OnMouseOver Hotspot Change Two Images

Hello, I am trying to create a rollover on a stock index graph when I rollover one of three geographic areas (Americas, Asia, Europe) on a separate image . So far I have been only able to create the rollover for the separate countries, without the second image. Here is the code I found and adapted:

<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>


<img alt="Bloomberg Tab" border="0" usemap="#Asia_map" height="30" src="http://images.bloomberg.com/r06/homepage/asia_home_tab.gif" id="Asia_pic" width="342" name="Asia_pic" class="flt_lft"/>
<map id="Asia_map" name="Asia_map">
<area shape="rect" coords="172,10,260,30" onmouseover="MM_swapImage('Asia_pic','','http://images.bloomberg.com/r06/homepage/europe_home_tab.gif',1)" alt="Euro Tab" onmouseout="MM_swapImgRestore()" href="http://www.bloomberg.com/index_eu.html"/>

<area shape="rect" coords="0,10,105,30" onmouseover="MM_swapImage('Asia_pic','','http://images.bloomberg.com/r06/homepage/us_home_tab.gif',1)" alt="US Tab" onmouseout="MM_swapImgRestore()" href="http://www.bloomberg.com/index_americas.html"/></map>


Also, I have been able to connect the two images by using the following code, but this only allows viewing two regions/corresponding graphs, instead of three - and it works only by rolling over the entire tab graph, instead of specific regions (hotspots):

<script type="text/javascript">
<!--

function roll(img_name1, img_src1, img_name2, img_src2,img_name3, img_src3)
{
document[img_name1].src = img_src1;
document[img_name2].src = img_src2;
document[img_name3].src = img_src3;
}

//-->
</script>

<a
onmouseover="roll('sub1', 'http://images.bloomberg.com/r06/homepage/europe_home_tab.gif', 'sub2', 'http://images.bloomberg.com/r06/homepage/HP_UKX.png')"
onmouseout="roll('sub1', 'http://images.bloomberg.com/r06/homepage/us_home_tab.gif', 'sub2', 'http://images.bloomberg.com/r06/homepage/HP_INDU.png')" href="http://images.bloomberg.com/r06/homepage/HP_INDU.png">

<img border="0" width="325"
height="30" src="http://images.bloomberg.com/r06/homepage/us_home_tab.gif" name="sub1" align="top"/>
</a>



<img width="325" src="http://images.bloomberg.com/r06/homepage/HP_INDU.png" name="sub2" height="175" align="left"/>


I have tried combining the two codes in various ways but so far without any luck. Any suggestions would be much appreciated!

Thanks!
Vetir39 is offline   Reply With Quote