zoukankan      html  css  js  c++  java
  • IE9兼容

    css hack兼容IE

    参考:https://blog.csdn.net/freshlover/article/details/12132801

    1.let、const更换为var声明

    2.箭头函数更换为function

    3.模板字符串``使用字符串拼接

    4.flex布局更换为float浮动和positon定位

    5.颜色rgb更换为16进制,rgba也可以通过识色转换为16机制,不过不透明,如果介意透明度的话可以外套一个div设置opacity透明度属性

    6.meta

    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">

    一、判断IE

        //IE浏览器
        var explorer = window.navigator.userAgent.toLowerCase();
        var ver = 9999
        if (explorer.indexOf("msie") >= 0) {
            ver = parseInt(explorer.match(/msie ([d.]+)/)[1]);
            // ver为IE版本  
        }

    二、placeholder不显示

        .inp {
            color: #cccccc;
        }
       <input type="text" name="search_name" id="search_name" placeholder="搜索" datavalue="搜索">
        <script>
            function placeholder(target) {
                $(target).val($(target).attr("datavalue")).addClass("inp");
                $(target).focus(function () {
                    if ($(this).val() == $(this).attr("datavalue")) {
                        $(this).val("").removeClass("inp");
                    }
    
                })
                $(target).blur(function () {
                    if ($(this).val() == "" || $(this).val() == $(this).attr("datavalue")) {
                        $(this).val($(target).attr("datavalue")).addClass("inp");
                    }
                })
            }
            // 如果是ie9及以下调用方法
            placeholder("#search_name")

    三、获取自定义属性‘data-’

                var dataset = {}
                if (!e.target.dataset) {
                    // var attrs = $(e.target).get(0).attributes
                    var attrs = e.target.attributes
                    for (var i = 0; i < attrs.length; i++) { //是否是data- 开头
                        var matchStr = attrs[i].name.match(/^data-(.+)/);
                        if (matchStr) { //data-auto-play 转成驼峰写法 autoPlay
                            name = matchStr[1].replace(/-([da-z])/gi, function (all, letter) {
                                return letter.toUpperCase();
                            });
                            dataset[name] = attrs[i].value;
                        }
                    }
                }
  • 相关阅读:
    英文哲理短句
    经历的一次诈骗
    英文哲理短句
    反思对待新人的方式
    Java 开源报表制作
    现在开始写字
    关于Visual C++ 6.0的调试技巧和经验总结
    一步一步教你实现CTreeCtrl 自绘
    VC中动态加载ODBC解决方法
    VC++程序编译链接的原理与过程
  • 原文地址:https://www.cnblogs.com/jing-zhe/p/12832247.html
Copyright © 2011-2022 走看看