Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
</head>
<body>
<img id="img1" src="http://www.vicsjavascripts.org/StdImages/1.gif" onclick="zxcRandomImage.Random('img1');"/>
<script type="text/javascript">
/*<![CDATA[*/
var zxcRandomImage={
Random:function(id){
var o=this['zxc'+id],n,ni;
if (o){
n=Math.floor(Math.random()*o.ary.length);
while (n==o.n){
n=Math.floor(Math.random()*o.ary.length);
}
o.n=n;
ni=new Image();
ni.src=o.ary[n]
this.load(o,ni);
}
},
Init:function(o){
var id=o.ImageID,ary=o.SRCArray,img=document.getElementById(id);
if (img&&ary instanceof Array&&ary.length>1){
o.img=img;
o.ary=ary;
o.n=-1;
this['zxc'+id]=o;
}
},
load:function(o,ni){
var oop=this;
clearTimeout(o.to);
if (ni.width<40){
return o.to=setTimeout(function(){ oop.load(o,ni); },200);
}
o.img.src=ni.src;
}
}
zxcRandomImage.Init({
ImageID:'img1',
SRCArray:[
'http://www.vicsjavascripts.org/StdImages/1.gif',
'http://www.vicsjavascripts.org/StdImages/2.gif',
'http://www.vicsjavascripts.org/StdImages/3.gif',
'http://www.vicsjavascripts.org/StdImages/4.gif',
'http://www.vicsjavascripts.org/StdImages/5.gif' // no commer
]
});
/*]]>*/
</script>
</body>
</html>
Bookmarks