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[*/
#slide {
position:absolute;left:100px;top:100px;width:200px;height:150px;overflow:hidden;background-Color:#FFFFCC;
}
#slide IMG{
position:absolute;left:0px;top:75px;width:200px;height:150px;
}
/*]]>*/
</style><script type="text/javascript">
/*<![CDATA[*/
function Slide(o){
var oop=this,obj=document.getElementById(o.ID),img=obj.getElementsByTagName('IMG')[0],to=o.Finish,to=typeof(to)=='number'?to:0,ms=o.Duration,ms=typeof(ms)=='number'?ms:1000;
this.obj=obj;
this.frto=[img.offsetTop,to];
this.ms=ms;
this.now=this.frto[0];
obj.onmouseover=function(){ oop.slide(img,true); }
obj.onmouseout=function(){ oop.slide(img,false); }
}
Slide.prototype={
slide:function(img,ud){
var e=window.event||arguments.callee.caller.arguments[0];
if (this.ckevt(e)){
this.animate(img,this.now,this.frto[ud?1:0],new Date(),this.ms);
}
},
animate:function(obj,f,t,srt,mS){
var oop=this,ms=new Date().getTime()-srt,now=(t-f)/mS*ms+f;
if (isFinite(now)){
this.now=now;
obj.style.top=now+'px';
}
if (ms<mS){
this.dly=setTimeout(function(){ oop.animate(obj,f,t,srt,mS); },10);
}
else {
this.now=t;
obj.style.top=t+'px'; }
},
ckevt:function(e){
var obj=e.relatedTarget?e.relatedTarget:e.type=='mouseout'?e.toElement:e.fromElement;
if (!obj||obj==this.obj){
return false;
}
while (obj.parentNode){
if (obj==this.obj){
return false;
}
obj=obj.parentNode;
}
return true;
}
}
/*]]>*/
</script>
<script type="text/javascript">
/*<![CDATA[*/
function Init(){
new Slide({
ID:'slide',
Finish:0,
Duration:1000
});
}
if (window.addEventListener){
window.addEventListener('load',Init, false);
}
else if (window.attachEvent){
window.attachEvent('onload',Init);
}
/*]]>*/
</script>
</head>
<body>
<div id="slide" ><img src="http://www.vicsjavascripts.org.uk/StdImages/Egypt5.jpg" alt="img" /></div>
</body>
</html>
Bookmarks