星空网 > 软件开发 > Java

js实现可关闭悬浮框广告特效,兼容(谷歌,火狐,Ie)

注意不能直接用close()命名关闭广告函数,避免冲突。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html ="http://www.w3.org/1999/xhtml"><head>  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>  <title>无标题文档</title>  <style type="text/css">    #apDiv1 {      position: absolute;      left: 251px;      top: 51px;      width: 529px;      height: 210px;      z-index: 2;      background-color: #0000FF;    }    #closebt {      position: absolute;      top: 0;      right: 0;      background: red;    }    #apDiv2 {      position: absolute;      left: 128px;      top: 381px;      width: 912px;      height: 18663px;      z-index: -1;      background-color: #FF0000;    }    -->  </style>  <script>    var xx = 0;    function init() {//获取元素的top值      xx = document.getElementById("apDiv1").offsetTop;    }    function aa() {      if (document.body.scrollTop) {//兼容谷歌        document.getElementById("apDiv1").style.top = xx + document.body.scrollTop + "px";      } else {//兼容ie,火狐        document.getElementById("apDiv1").style.top = xx + document.documentElement.scrollTop + "px";      }    }    window.onscroll = aa;    function closetext() {      document.getElementById("closebt").style.display="none";      document.getElementById("apDiv1").style.display="none";    }  </script></head><body onload="init()"><div id="apDiv1">  <span id="closebt"><a href="#" onclick="closetext()">可关闭</a></span></div><div id="apDiv2"></div></body></html>

 




原标题:js实现可关闭悬浮框广告特效,兼容(谷歌,火狐,Ie)

关键词:JS

JS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

《亚马逊45种封店类型》!不懂别做亚马逊!:https://www.kjdsnews.com/a/738899.html
新年首场大促!亚马逊日本站将推出“Amazon Hatsuuri”促销活动:https://www.kjdsnews.com/a/738900.html
做速卖通如何应对知识产权侵权:https://www.kjdsnews.com/a/738901.html
浙江湖州跨境电商综试区业务量首次破百亿:https://www.kjdsnews.com/a/738902.html
wayfair运营实操:waymore页面设置(下):https://www.kjdsnews.com/a/738903.html
速卖通平台重复铺货以及SKU作弊的注意事项:https://www.kjdsnews.com/a/738904.html
十堰有哪些官方网站:https://www.vstour.cn/a/404229.html
北京景点恢复开放通知 北京景区关闭通知:https://www.vstour.cn/a/404230.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流