
March 30th, 2008, 09:58 PM
|
|
Contributing User
|
|
Join Date: Feb 2008
Posts: 73
Time spent in forums: 18 h 51 m 55 sec
Reputation Power: 1
|
|
|
Rollover image with onclick problem
Hi,
I simply want this script to when I roll over mouse is changes image, then when I Onclick I want it to go to a different image and stay there but when I take the mouse away it changes back? Any help, i want to be able to click it again then changes back to normal with the normal rollover image etc but once clicked it stays on the clicked image so sorta lke when I Onclick is disables the rollover until I click on the image again,
Code:
<html>
<head>
<title>test</title>
<script language="JavaScript" type="text/JavaScript">
var q=0;
var root='lotto/';
function swapImg(ima){
nr = ima.getAttribute('src').split('/');
nr = nr[nr.length-1].split('.')[0];
if(q==0){ima.setAttribute('src',root+nr+'.jpg');q+ +;}
else{ima.setAttribute('src',root+nr+'.gif');q--;}
}
</script>
<script language="JavaScript" type="text/JavaScript">
<!--
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;
}
//-->
</script>
<script language="JavaScript" 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_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>
</head>
<body>
<div align="center"><a onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('no01','','lotto/01_over.gif',1)"><img src="lotto/01.gif" name="no01" width="40" height="40" border="0" onclick="swapImg(this)"></a>
</body>
</html>
|