Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<style type="text/css">
<!--
#bar {
position:absolute;z-Index:101;left:0px;top:-50px;width:100%;height:100px;background-Color:red;
}
-->
</style>
<script type="text/javascript">
<!--
/*
A function to animate an element up or down
The element must be assigned a unique ID name
The element must be assigned a CSS position of 'absolute' or 'relative'
and the appearance defined by CSS class rule or inline HTML or style
The script is executed by calling function zxcBar passing script options as parameters
e.g.
zxcBar('bar',0,1000);
where
parameter 0 = the unique ID name of the element. (string)
parameter 1 = the new top position of the element. (number)
parameter 2 = (optional) the animation duration in milli seconds. (number, default - 1000)
*/
function zxcBar(id,to,ms){
var o=zxcBar['zxc'+id],obj=document.getElementById(id);
if (obj&&typeof(to)=='number'){
if (!o){
zxcBar['zxc'+id]=o={
now:obj.offsetTop,
ms:typeof(ms)=='number'?ms:1000
}
}
clearTimeout(o.dly);
this.animate(o,obj,o.now,to,new Date(),typeof(ms)=='number'?ms:o.ms);
}
}
function animate(o,obj,f,t,srt,mS){
var oop=this,ms=new Date().getTime()-srt,now=(t-f)/mS*ms+f;
if (isFinite(now)){
o.now=now;
obj.style.top=now+'px';
}
if (ms<mS){
o.dly=setTimeout(function(){ oop.animate(o,obj,f,t,srt,mS); },10);
}
else {
o.now=t;
obj.style.top=t+'px';
}
}
//-->
</script></head>
<body>
<div id="bar" onmouseover="zxcBar('bar',0,1000);" onmouseout="zxcBar('bar',-50);" >
<a href=#" > content goes here </a>
</div>
</body>
</html>
Bookmarks