zoukankan      html  css  js  c++  java
  • modernizr.js

    1.判断浏览器是否支持 h5

            if(Modernizr.canvas){
                alert(123);
            }else{
                alert(321);
            }    

    2.判断浏览器是否支持 canvas

        function supert_canvas(){
            if(Modernizr.canvas){
                alert("是");
            }else{
                alert("否");
            }
        
        }

    或者

    function supert_canvas(id){ 
      return !! document.getElementById(id).getContext("2d");
    }

    3.判断浏览器是否支持 canvas 的fliiText()

     if(Modernizr.canvastext){
          alert(123);
     }else{
          alert(321);
    }    

    或者

    function supert_canvas1_fillText(){
       var canvas1 = document.getElementById("canvas1");
       var context = canvas1.getContext("2d");
        return typeof context.fillText == 'function';
    }

    4.判断浏览器是否支持 视频播放器

    function supert_video (id){
        return !! document.getElementById(id).canPlayType;
    }

    也可以

     if(Modernizr.video){
          alert("支持");
     }else{
          alert("不支持");
    }   

    4.判断浏览器是否支持 webM 视频 编码格式

    function support_webm_video(){
      if(!support_video()){ return false}
      var v = document.createElement("video");
      return v.canPlayType('video/webm; codecs="vp8,varbis"');  
    
    }

    或者

    function supports_webm_video(){
        if(Modernizr.video){
            // 可以播放视频了,但是播放哪一种格式呢?
            if(Modernizr.video.oog){
                // 尝试在 Ogg 容器中使用 Ogg Theora + Vorbis 
            }else if (){
                // 尝试在 MP4 容器中使用 h.264 视频 + AAC  音频
            }
        
        }
    }

    5.判断浏览器是否支持 本地存储

    function support_local_storage(){
    
        return ('localStorage' in window ) && window['localStorage'] != null;
    }   

    或者

        if(Modernizr.localstorage){
            alert("ok");
        }else{
            alert("no ok");
        }

    6.判断浏览器是否支持 web workers

    function support_web_workers(){
        return !! window.Worker;
    
    }

    或者

            if(Modernizr.webworkers){
            }else{
            }

    7.判断浏览器是否支持 web workers

    function support_offline(){
        return !! window.applicationcache;
    }

    或者

            if(Modernizr.applicationcache){
            }else{
            }

    8.判断浏览器是否支持 geolocation 

    function support_geolocation(){
        return !! window.geolocation;
    }

    或者

            if(Modernizr.geolocation){
            }else{
            }

    9.判断浏览器是否支持 输入框类型

            if(Modernizr.inputtypes.data){
            }else{
            }

    10.判断浏览器是否支持 占位文本

            if(Modernizr.input.placeholder){
            }else{
            }

    11.判断浏览器是否支持 表单自动聚焦

            if(Modernizr.input.autofocus){
            }else{
            }

    或者

    function support_input_autofocus(){
        return  'autofocus' in document.createElement('input');
    }

    11.判断浏览器是否支持 微数据

    function support_input_autofocus(){
        return !! window.getItems;
     }
  • 相关阅读:
    greenplum日常维护手册
    Android UI界面基本属性 大全
    Listview 选项按下去黑了所有按钮的解决方法 ——android:cacheColorHint=“#00000000”
    【转】Android应用程序模块详解
    android退出有多个activity的应用
    启动模式"singleTask"和FLAG_ACTIVITY_NEW_TASK具有不同的行为!
    Android 按两次back键退出 效率最高版
    【转】跑马灯效果
    Sundy笔记__Git版本控制
    如果你想用对话框代替一个activity的话,可以设置activity的主题属性
  • 原文地址:https://www.cnblogs.com/mjorcen/p/4447064.html
Copyright © 2011-2022 走看看