您的位置:首页 > 其它

一种JS实现的广告打开特效

2007-10-22 15:57 661 查看
代码

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>show</title>
<style type="text/css">
#show{
display:none;
margin:0px auto;
background-color:#FF0000;
}
#txt{
width:760px;
height:30px;
margin:0px auto;
background-color:#efefef;
}
</style>
</head>
<body>
<div id=show>
</div>
<div id=txt>
<a href="#" onClick="show()">Open</a> <a href="#" onClick="show2()">Close</a>
</div>
<script type="text/javascript">
function show(){
if (!document.getElementById) return false;
if (!document.getElementById("show")) return false;
var show = document.getElementById("show");
show.style.width = "0px";
show.style.height = "0px";
show.style.display = "block";
movement = setTimeout("animation()",0)
}
function animation(){
if (!document.getElementById) return false;
if (!document.getElementById("show")) return false;
var show = document.getElementById("show");
var xpos = parseInt(show.style.width);
var ypos = parseInt(show.style.height);
if (xpos == 760 && ypos == 420){
return true;
}
if (xpos < 760){
xpos+=10
}
if (xpos > 760){
xpos-=10
}
if (ypos < 420){
ypos+=10
}
if (ypos > 420){
ypos-=10
}
show.style.width = xpos + "px";
show.style.height = ypos + "px";
movement = setTimeout("animation()",0);
}
function show2(){
if (!document.getElementById) return false;
if (!document.getElementById("show")) return false;
var show = document.getElementById("show");
show.style.width = "760px";
show.style.height = "420px";
show.style.display = "block";
movement = setTimeout("animation2()",0)
}
function animation2(){
if (!document.getElementById) return false;
if (!document.getElementById("show")) return false;
var show = document.getElementById("show");
var xpos = parseInt(show.style.width);
var ypos = parseInt(show.style.height);
if (xpos == 0 && ypos == 0){
return true;
}
if (xpos < 0){
xpos+=10
}
if (xpos > 0){
xpos-=10
}
if (ypos < 0){
ypos+=10
}
if (ypos > 0){
ypos-=10
}
show.style.width = xpos + "px";
show.style.height = ypos + "px";
movement = setTimeout("animation2()",0);
}
</script>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: