zoukankan      html  css  js  c++  java
  • 每日日报7月22日

    1.今天学习了创建web应用

    一.使用节点固定位置

    div_div.currentStyle /*可用于判断是否为IE浏览器*/
    div_div.currentStyle.left /*获取默认浏览的左边距值*/
    div_div.currentStyle.top /*获取默认浏览的上边距值*/
    document.defaultView.getComputedStyle(div_div,null).left /*获取当前计算机浏览器的左边距值*/
    document.defaultView.getComputedStyle(div_div,null).top /*获取当前计算机浏览器的上边距值*/


    /*scrollLeft|方法是获取滚动时候的左边距,由于浏览器兼容性问题需要使用body或则documentElement,*/
    document.documentElement.scrollLeft||document.body.scrollLeft


    window,οnlοad=huoqubianju; /*onload  读取完代码后自动执行一次该方法*/
    window.οnscrοll=jisuanbianju; /*鼠标通过滚动的形式触发相应的方法*/

    参考代码:

    <script type="text/javascript">
    
       var oleft;
       var otop;
       var div_div =document.getElementById("adver")
    
       function huoqubianju() {            /*获得左边距以及上边距的具体*/
    if(div_div.currentStyle){        /*判断是否为IE浏览器*/
    oleft = parseInt(div_div.currentStyle.left);       /*如是就获取该值*/
    otop = parseInt(div_div.currentStyle.top);
          }else{                         /*否则执行当前电脑风格的属性*/
    oleft = parseInt(document.defaultView.getComputedStyle(div_div,null).left);
             otop = parseInt(document.defaultView.getComputedStyle(div_div,null).top);
          }
    
        }
    
       function jisuanbianju() {     /*计算滚动时候的边距*/
          /*由于兼容性的问题,需要通过documentElement或则body进行获取*/
    var nleft =parseInt(document.documentElement.scrollLeft||document.body.scrollLeft);
          var ntop = parseInt(document.documentElement.scrollTop||document.body.scrollTop);
    
    
          /*获得了两个属性后均通过style.top或left进行赋值*/
    div_div.style.top=otop+ntop+"px";
          div_div.style.left=oleft+nleft+"px";
        }
    
        window,onload=huoqubianju;       /*onload  读取完代码后自动执行一次该方法*/
    window.onscroll=jisuanbianju;     /*鼠标通过滚动的形式触发相应的方法*/
    </script>
    2.没有遇到问题
    3.明天打算学习Jsp运行原理
  • 相关阅读:
    程序员常用字体(vs2008字体修改方案)
    Struts 与 Velocity 的集成
    CheckBox Button
    WINDOWS MOBILE winnet开发心得
    Change background color of a UIAlertView
    Windows Mobile 自定义控件(一)
    ZNLog
    获取磁盘空间大小
    iPhone开发:UIImage的一系列操作
    Windows Mobile 自定义控件(二)
  • 原文地址:https://www.cnblogs.com/wanghaoning/p/13430414.html
Copyright © 2011-2022 走看看