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>
<style type="text/css">
/*<![CDATA[*/
.parent {
position:absolute;z-Index:101;left:0px;top:50px;width:100%;height:75px;border:solid red 0px;
}
#img1 {
position:absolute;left:0px;top:0px;width:100px;height:75px;
/* Moz */
opacity: .5;
/* IE5-7 */
filter: alpha(opacity=50);
/* IE8 */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
}
/*]]>*/
</style></head>
<body>
<div class="parent" >
<img id="img1" src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" alt="img" />
</div>
<script type="text/javascript">
/*<![CDATA[*/
function zxcMarquee(o){
var obj=document.getElementById(o.ID),p=obj.parentNode,w=obj.offsetWidth,now=p.offsetWidth,sec=o.Duration;
p.style.visibility='hidden';
p.style.overflow='hidden';
obj.style.visibility='visible';
obj.style.left=now+'px';
this.obj=obj;
this.p=p;
this.to=w;
this.max=now;
this.now=now;
this.ms=typeof(ms)=='number'?sec*1000:10000;
this.dly=null;
this.marquee();
}
zxcMarquee.prototype={
marquee:function(){
clearTimeout(this.dly);
this.mS=this.ms*Math.abs((this.p.offsetWidth+this.to)/this.max);
this.animate(this.now,-this.to,new Date(),this.mS);
},
animate:function(f,t,srt,mS){
var oop=this,ms=new Date().getTime()-srt,now=Math.floor((t-f)/mS*ms+f);
if (isFinite(now)){
this.now=now;
}
this.obj.style.left=this.now+'px';
if (ms<this.mS){
this.dly=setTimeout(function(){ oop.animate(f,t,srt,mS); },10);
}
else {
this.now=this.p.offsetWidth;
this.marquee();
}
}
}
new zxcMarquee({
ID:'img1', // the unique ID name of the scrolling element. (string)
Duration:10 //(optional) the duration of scroll in seconds. (number, default = 10)
});
/*]]>*/
</script>
</body>
</html>
Bookmarks