zoukankan
html css js c++ java
首页头部下拉广告设计(javascript)
加在Head中
<
script type
=
"
text/javascript
"
language
=
"
javascript
"
>
var
intervalId
=
null
;
function
slideAd(id,nStayTime,sState,nMaxHth,nMinHth)
{
this
.stayTime
=
nStayTime
*
1000
||
3000
;
this
.maxHeigth
=
nMaxHth
||
330
;
//
广告最大高度
this
.minHeigth
=
nMinHth
||
1
;
this
.state
=
sState
||
"
down
"
;
var
obj
=
document.getElementById(id);
if
(intervalId
!=
null
)window.clearInterval(intervalId);
function
openBox()
{
var
h
=
obj.offsetHeight;
obj.style.height
=
((
this
.state
==
"
down
"
)
?
(h
+
5
) : (h
-
5
))
+
"
px
"
;
if
(obj.offsetHeight
>
this
.maxHeigth)
{
window.clearInterval(intervalId);
intervalId
=
window.setInterval(closeBox,
this
.stayTime);
}
if
(obj.offsetHeight
<
this
.minHeigth)
{
window.clearInterval(intervalId);
obj.style.display
=
"
none
"
;
}
}
function
closeBox()
{
slideAd(id,
this
.stayTime,
"
up
"
,nMaxHth,nMinHth);
}
intervalId
=
window.setInterval(openBox,
2
);
}
<
/
script>
加在Body下面
<
div
id
="slideAD"
style
="overflow: hidden; height: 0; padding-left:10px; 985px"
><
div
id
="hd"
><
img
src
="/img/close.gif"
alt
="关闭"
onclick
="slideAd('slideAD',5,'up');return false;"
/></
div
>
<
div
align
="center"
>这里插入相应的图片或flash
</
script
></
div
>
</
div
>
设置当页面完全加载之后执行,10MS 检测一次
<
script type
=
"
text/javascript
"
>
<!--
function
chk()
{
(
this
.document.readyState
==
"
complete
"
)
?
slideAd(
'
slideAD
'
,
8
):setTimeout(
'
chk()
'
,
10
);
}
chk();
//
-->
<
/
script>
查看全文
相关阅读:
【redis】--安全
【redis】-- 数据备份和恢复
2018.2.8 cf
寒假零碎的东西 不定时更新补充.......
hdu 1018
2018寒假acm训练计划
UVAlive 7466
母函数
简单数学题(水的不能在水的题了)
随便写写的搜索
原文地址:https://www.cnblogs.com/kingboy/p/1042374.html
最新文章
js的reduce累加器
学习使用add()()()迭代调用,柯里化处理
app海外推广——如何设置搜索关键字?
App Store优化推广 如何提高海外搜索排名
手游海外推广策略整理 让你不再毫无头绪
一个好的手游APP如何加强海外推广
我们的APP海外推广之路,让下载量从几百个到上百万
django 学习-1
Java中的内存
Java中JDK,JRE和JVM之间的关系
热门文章
【jdk1.8源码分析】目录
【jdk1.8源码分析】HashMap
将初始化容量转化大于或等于最接近输入参数的2的整数次幂的数
线程安全
【jdk1.8源码分析】总章
学习python -- 第022天 filter函数
学习python -- 第022天 map函数
学习python -- 第022天 zip函数
面试经验02--银行科技岗(广东农行)
mysql和redis的主要区别
Copyright © 2011-2022 走看看