国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

超棒的javascript頁面頂部卷動廣告效果

2019-11-21 01:51:32
字體:
來源:轉載
供稿:網友

前言

這篇文章主要介紹了關于利用javascript實現的超棒的頁面頂部卷動廣告效果,主要通過控制圖片外層div來實現的,下面話不多說了,來一起看看詳細的介紹吧。

實例代碼:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>無標題文檔</title><style type="text/css"> <!-- body { margin:0;background:#000; } img { border:0; } --> </style> <script type="text/javascript"> <!-- var nowheight=0;  //初始廣告層高度 var maxheight=224;  //廣告層最大高度 var adobj; var opendiv; var closdiv; var addfunc; var handobj; var reducefunc;     var speed=7;    //層卷動速度 function showtopad() {   adobj=document.getElementById("bigad");   opendiv=document.getElementById("opendiv");   closdiv=document.getElementById("closdiv");   if (nowheight<=0) {     opendiv.style.display="none";     adobj.style.display="block";     addfunc=setInterval("addheight()",1);   } } function closetopad() {   if (nowheight>0) {     callreduceheight();     if (typeof(handobj)=="number") {       clearTimeout(handobj);     }   } } function addheight() {   nowheight+=speed;   if (nowheight>maxheight) {     clearInterval(addfunc);     closdiv.style.top=maxheight-30;     closdiv.style.display="block";     handobj=setTimeout("callreduceheight()",6000);     return;   }   adobj.style.height=nowheight+"px"; } function callreduceheight() {   closdiv.style.display="none";   reducefunc=setInterval("reduceheight()",1); } function reduceheight() {   adobj.style.height=nowheight+"px";   nowheight-=speed;   if (nowheight<=0) {     clearInterval(reducefunc);     adobj.style.display="none";     opendiv.style.display="block";     return;   } } //--> </script> </head><body>  <div id="opendiv" style="position:absolute;top:3px;right:3px;z-index:10;padding:3px;border:1px #000 solid; cursor:hand;background:#fff;"><span onclick="showtopad()">打開</span></div>   <div id="closdiv" style="position:absolute;right:4px;z-index:10;padding:3px;border:1px #000 solid;display:none;cursor:hand;background:#fff;"><span onclick="closetopad()">關閉</span></div>      <div id="bigad" style="width:1003px;height:0;overflow:hidden;display:none;">     <a href="http://www.survivalescaperooms.com/" target="_blank">       <img src="http://www.survivalescaperooms.com/upload/20071201215241934.jpg">     </a>   </div>   <p style="margin:5px;text-align:center;font-weight:bold;font-size:14px;color:#fff;">     上面是廣告,你可以點擊看看效果!^_^   </p> </body></html>

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對武林網的支持。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 修文县| 静宁县| 荆州市| 偏关县| 辽宁省| 黄石市| 绥江县| 衡阳市| 怀集县| 乐至县| 台中市| 库车县| 临邑县| 固镇县| 囊谦县| 旬邑县| 金阳县| 读书| 汝城县| 玛沁县| 石楼县| 若尔盖县| 榆社县| 霞浦县| 永春县| 鹤峰县| 常德市| 福州市| 贵南县| 普安县| 全州县| 桑日县| 鹤山市| 浦城县| 郧西县| 延安市| 昆明市| 延安市| 千阳县| 佳木斯市| 诸城市|