• Javascript 广告定位


    <!DOCTYPE html>
    <html>
    <head>
     <meta charset="utf-8">
     <title></title>
     <style type="text/css">
      #ad{
       position:absolute;
       top:120px;
       left:50px;
       100px;
       height:200px;
       background-color:#333;
       color:#fff;
      }
     </style>
     
     <script type="text/javascript">
      window.onload=init;
      window.onscroll=go;
      var oldTop;
      
      function init(){
      
       var ad=document.getElementById("ad");
       
       //取对象原始的top值
       if(window.getComputedStyle){
        oldTop= parseInt( window.getComputedStyle(ad,null).top );
       }else{
        //IE
        oldTop= parseInt(ad.currentStyle.top);
       }
      }
      function go(){
       //浏览器滚动的距离
       var top=document.documentElement.scrollTop;
       
       document.getElementById("ad").style.top= parseInt(top)+oldTop +"px";
       
      }
      //关闭广告
      function closeAd(){
       var ad=document.getElementById("ad");
       ad.parentNode.removeChild(ad);
      }
      
     </script>
    </head>
    <body>
     <div id="ad"><a href="javascript:;" onclick="closeAd()">X</a><a class="close" onclick="this.parentNode.parentNode.removeChild(this.parentNode)">close</a>广告</div>
     <div style="height:5000px;">sss</div>
     
    </body>
    </html>

  • 相关阅读:
    sublime问题:失去焦点自动保存
    sublime问题:Tab键不缩进
    sublime问题:默认的中文字体显示异常
    pip换源 解决下载速度慢
    Oracle问题:ORA-01843: 无效的月份
    Eclipse设置自动生成的javadoc
    Java命名规范
    redis的道面试题, 有这一篇就足够了
    批量编译生成python的pyd文件
    测试种类大汇总(45类)
  • 原文地址:https://www.cnblogs.com/wicub/p/3123054.html
Copyright © 2020-2023  润新知