一个滑动展开/收缩广告实例
2007-08-01 18:52
232 查看
一个滑动展开/收缩广告
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<title> 代码实例:滑动展开/收缩广告 </title>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="author" content="XXX,XXX@gmail.com">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="keywords" content="代码实例:滑动展开/收缩广告" />
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script type="text/javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var intervalId = null;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.stayTime=nStayTime*1000 || 3000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.maxHeigth=nMaxHth || 90;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.minHeigth=nMinHth || 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.state=sState || "down" ;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var obj = document.getElementById(id);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(intervalId != null)window.clearInterval(intervalId);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function openBox()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var h = obj.offsetHeight;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
obj.style.height = ((this.state == "down") ? (h + 2) : (h - 2))+"px";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if(obj.offsetHeight>this.maxHeigth)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
window.clearInterval(intervalId);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
intervalId=window.setInterval(closeBox,this.stayTime);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (obj.offsetHeight<this.minHeigth)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
window.clearInterval(intervalId);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
obj.style.display="none";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function closeBox()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
slideAd(id,this.stayTime,"up",nMaxHth,nMinHth);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
intervalId = window.setInterval(openBox,10);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<body style="margin:0;padding:0;font-size:14px;">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<div id="MyMoveAd" style="background:#ff0;height:12px;overflow:hidden;">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<ul>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</ul>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</div>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<p>代码实例:<strong>滑动展开/收缩广告</strong> 请刷新页面,再次观看演示效果</p>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script type="text/javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
<!--
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
slideAd('MyMoveAd',2);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
-->
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</html>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<title> 代码实例:滑动展开/收缩广告 </title>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="author" content="XXX,XXX@gmail.com">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<meta name="keywords" content="代码实例:滑动展开/收缩广告" />
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script type="text/javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var intervalId = null;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.stayTime=nStayTime*1000 || 3000;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.maxHeigth=nMaxHth || 90;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.minHeigth=nMinHth || 1;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
this.state=sState || "down" ;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var obj = document.getElementById(id);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
if(intervalId != null)window.clearInterval(intervalId);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function openBox()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
var h = obj.offsetHeight;
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
obj.style.height = ((this.state == "down") ? (h + 2) : (h - 2))+"px";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if(obj.offsetHeight>this.maxHeigth)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
window.clearInterval(intervalId);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
intervalId=window.setInterval(closeBox,this.stayTime);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
if (obj.offsetHeight<this.minHeigth)...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
window.clearInterval(intervalId);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
obj.style.display="none";
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)
function closeBox()...{
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
slideAd(id,this.stayTime,"up",nMaxHth,nMinHth);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
intervalId = window.setInterval(openBox,10);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
}
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</head>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<body style="margin:0;padding:0;font-size:14px;">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<div id="MyMoveAd" style="background:#ff0;height:12px;overflow:hidden;">
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<ul>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<li>这里是广告内内容</li>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</ul>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</div>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
<p>代码实例:<strong>滑动展开/收缩广告</strong> 请刷新页面,再次观看演示效果</p>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)
<script type="text/javascript">...
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
<!--
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)
slideAd('MyMoveAd',2);
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)
-->
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</script>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</body>
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)
</html>
相关文章推荐
- 滑动展开-收缩广告代码实例效果
- 向下滑动展开/收缩JS广告
- 滑动展开/收缩广告
- JS右下角广告窗口代码(可收缩、展开及关闭)
- 一个表格收缩展开的函数
- joomla1.5开发一个广告随机显示模块实例
- 滑动文本标签,一个类解决广告轮播 UIScrollView
- 用jQuery实现asp.net 2.0 treeview控件完全无刷新操作实例(AJAX的增、删、改、选择以及展开收缩节点)
- Android 用Json解析请求图片写的一个ViewPager广告轮播、带滑动小圆点
- 一个表格收缩展开的函数
- 分享一个可展开收缩的右侧悬浮QQ在线客服代码
- 用Fragment设置一个广告图片滑动
- 一个表格收缩展开的例子(IE6/FF2)
- 用Repeater做的一个可以收缩展开的列表项目
- 一个侧屏滑动操作的实例(仿遇见)之二:布局XML
- 一个回滚段收缩的实例
- Jquery实例2:可收缩展开的级联菜单与局部刷新
- 每日一个js实例12--广告切换效果
- Android 用Json解析请求图片写的一个ViewPager广告轮播 , 带滑动小圆点 ,完美解决了三张图片引起的滑动问题