一种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>
<!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>
相关文章推荐
- JS实现悬浮移动窗口(悬浮广告)的特效
- JS实现悬浮移动窗口(悬浮广告)的特效
- JS实现悬浮移动窗口(悬浮广告)的特效
- 原生JS实现漂浮广告的一种方法(Demo)
- 网站上经常使用的第一次打开弹出广告特效
- JS实现鼠标双击页面向下滚动,单击停止的特效
- 前端特效:使用js实现奇幻水母效果
- 《js-图片漂浮广告代码-特效》
- JS特效:用鼠标事件实现图片的渐显效果
- js实现的星星评分特效
- 用js实现瀑布流的一种简单方法
- js两种实现网页图片滚动的方法 和一种切换的方法
- js实现瀑布流的一种简单方法实例分享
- JS实现点击网页判断是否安装app并打开否则跳转app store
- 原生js和jquery实现图片轮播特效
- js实现从右向左缓缓浮出网页浮动层广告的方法
- js实现简单的左右两边固定广告效果实例
- JS特效代码大全(二)能记录cookie的顶部伸缩广告
- 基于iscroll.js实现下拉刷新和上拉加载特效
- 【JS】两侧横幅小广告特效