功能说明:
滑动展开/收缩广告效果,可指定:广告完全展开时的停留时间,最大高度。 兼容浏览器:
IE5.0+、FF1.06+、Opera8.0+
实例代码:
- <html>
- <head>
- <title> 代码实例:滑动展开/收缩广告 </title>
- <meta http-equiv="content-type" content="text/html; charset=gb2312" />
- <meta name="author" content="枫岩,CNLei.y.l@gmail.com">
- <meta name="keywords" content="代码实例:滑动展开/收缩广告" />
- <script type="text/javascript">
- var intervalId = null;
- function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){
- this.stayTime=nStayTime*1000 || 3000;
- this.maxHeigth=nMaxHth || 90;
- 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 + 2) : (h - 2))+"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,10);
- }
- </script>
- </head>
- <body style="margin:0;padding:0;font-size:14px;">
- <div id="MyMoveAd" style="background:#ff0;height:12px;overflow:hidden;">
- <ul>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- <li>这里是广告内内容</li>
- </ul>
- </div>
- 代码实例:<strong>滑动展开/收缩广告</strong>
- 请刷新页面,再次观看演示效果
- <script type="text/javascript">
- <!--
- slideAd('MyMoveAd',2);
- -->
- </script>
- </body>
- </html>
复制代码
|