zoukankan      html  css  js  c++  java
  • 解决兼容的方法!

    1.清除浮动的兼容性:

      清除浮动在低版本浏览器不可以使用,需要处理兼容性加一个.clearfix{*zoom:1}

    2.rgb和rgba和opacity的兼容性

      rgb和rgba在ie低版本中不支持。需要加一个filter:alpha(opacity=50);

    3.解决css3中的兼容性

      chrome(谷歌浏览器)的前缀-webkit-

      firefox(火狐浏览器)的前缀-moz-

      ie的前缀-ms-

      poera(欧朋)的前缀-o-

    4.LE6不支持document.documentElement

      兼容写法

      var w=document.documentElement.body.clieneWidth

      获取浏览器可见区的宽度

    5.获取元素的子节点

      元素。childNodes这个属性有兼容性,标准浏览器会获取到文本节点而低版本的不会,所以建议使用children这个属性

      标准下  元素.firstElementChild

      非标准下  元素.firstChild

      兼容下写法

      var list=document.getElementById("list")

      var first=list.firstElementChild||list.firstChild

      console.log(first)

    6.js解救兼容性的方法

      1.||

        var dd=document.documentElement.client.clientWidth||document.body.clientwidth

      2.if() else{}

        if(window.getComputedStyle){

          csss=window.getComputedStyle(aa,null)

        }else{

         csss=aa.currentStyle

        }

        console.log(csss)

      3.try{}catch(err){}

      必须在报错的条件下,和if else比较性能上比较差,万不得已的情况下不能下

    7.获取浏览器body的属性是有兼容的

      兼容写法:var ss=document.documentElement||document.body

    8.Event的兼容性

      在chrome下event是undefined;在ie低版本下null;在火狐下会报错

      documen.onclick=function(e){

        var e=e||wondow.event

      }

    9.mouseevent兼容性

      标准浏览器可以直接读取,但IE不行

      document.onclick=function(ev){

        var ev=e||window.event

      }

    10.event对象的兼容性:

      clientX和clientY是鼠标到浏览器窗口的左上角的距离

      pageX和pageY是鼠标到网页左上角的距离坐标,但IE低版本没有这个属性

      在IE下怎么算pageY的值?用clicnt+scro||Top

    11.阻止事件冒泡呃兼容性方法

      1.event.vanceIBubble()

      2.event.stopPropagation?event,stopPropagation():event.cancelBubble=ture

    12.阻止事件默认行为兼容性

      Event,peventDefault?Event.prevent.preventDefault():event.returnValue=false

      

  • 相关阅读:
    多线程学习纪要
    字符编码ASCII、Unicode、UTF-8以及验证
    C# 自定义特性Attribute要点
    Java --- 流操作
    数据库 --- 索引
    Java -- 枚举
    mybatis --- 使用通用mapper或者mybatis-plus进行映射时,当数据库中有大写字母,自定义映射的字段名。
    后端 --- 快速创建一个sb项目 (使用spring官网的https://start.spring.io)
    数据库 --- decimal类型测试
    Java --- 线上故障调优01 打印堆栈信息
  • 原文地址:https://www.cnblogs.com/xwzs/p/12561870.html
Copyright © 2011-2022 走看看