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>
查看全文
相关阅读:
CoreLocation
通知(NSNotificationCenter)
加载xib文件
UITextField
UIButton
UILabel
UIAlertController
layoutSubviews
Java AQS详解(转)
Java中synchronized
原文地址:https://www.cnblogs.com/kingboy/p/1042374.html
最新文章
servlet配置log4J
一个利用pojo类从前端页面request中获取参数的小框架~
装饰器模式(think in java中的设计模式)
享元模式(think in java中的设计模式)
knn算法---java简单实现
StringBuffer的拼接效率小细节
模板方法模式(think in java中的设计模式)
hibernate简单入门教程(五)---------检索策略
JSch
浅析Spring中的注解
热门文章
Spring中depends-on的作用是什么?
注解@PostConstruct与@PreDestroy讲解及实例
MyBatis的几种批量操作
JAVA设计模式之工厂模式
spring mvc+mybatis+多数据源切换
Log4J日志配置详解
java 深入浅出工厂模式
MongoDB设置访问权限、设置用户
事件处理机制
简单的翻牌
Copyright © 2011-2022 走看看