zoukankan      html  css  js  c++  java
  • 检测浏览器是否支持range

    昨天的滑块建立在Input range这个基础上  这是IOS5.0及以后才支持的,而且在android2.3以下表现也不对

    昨天的检测方式

    var input = document.createElement('input');
    input.setAttribute('type','range')
    console.log(input.type == 'range')

    不能完全检测出不支持。今天找到了modernizr http://modernizr.com/docs/#installing       

    看了人家的方式 ,感觉老外真是有耐心啊

    inputElem.setAttribute('type', inputElemType = props[i]);
    bool = inputElem.type !== 'text';
    
    if ( bool ) {
    
                        inputElem.value         = smile;
                        inputElem.style.cssText = 'position:absolute;visibility:hidden;';
    
                        if ( /^range$/.test(inputElemType) && inputElem.style.WebkitAppearance !== undefined ) {
    
                          docElement.appendChild(inputElem);
                          defaultView = document.defaultView;
    
                                            bool =  defaultView.getComputedStyle &&
                                  defaultView.getComputedStyle(inputElem, null).WebkitAppearance !== 'textfield' &&
                                                                                      (inputElem.offsetHeight !== 0);
    
                          docElement.removeChild(inputElem);
    
                        } 
    }
  • 相关阅读:
    Java Socket
    路由器和交换机的区别
    OSI七层协议
    traceroute命令
    DNS递归和迭代原理
    出栈入栈顺序问题
    A记录、CNAME记录、MX记录
    DNS解析原理
    RAID磁盘阵列0、1、5、10
    http状态码
  • 原文地址:https://www.cnblogs.com/vaal-water/p/3173251.html
Copyright © 2011-2022 走看看