• 常用JS代码


    // 移动设备侦测
    var isMobile = {
      Android: function () {
        return navigator.userAgent.match(/Android/i);
      },
      BlackBerry: function () {
        return navigator.userAgent.match(/BlackBerry/i);
      },
      iOS: function () {
        return navigator.userAgent.match(/iPhone|iPad|iPod/i);
      },
      Opera: function () {
        return navigator.userAgent.match(/Opera Mini/i);
      },
      Windows: function () {
        return navigator.userAgent.match(/IEMobile/i);
      },
      any: function () {
        return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
      }
    };
    

    判断IE

      isIE: function (num) {
        var name = navigator.appVersion.toUpperCase();
        return num ? name.match(/MSIE (d)/) && name.match(/MSIE (d)/)[1] == num : /MSIE (d)/.test(name);
      }
    

    创建弹窗

    function showMsg(msgContent){   
        var box = document.createElement("div");
        var msg = document.createElement("div");
        box.setAttribute("id", "showMsgBox");
        msg.setAttribute("id", "msgBox");
        with(box.style){
            position = "absolute";
            top = 0;
            left = 0;
            bottom = 0;
            right = 0;
            background = "rgba(255,255,255,.6)";
        }
        with(msg.style){
            margin = "0 auto";
            width = "500px";
            height = "400px";
            marginTop = "100px";
            padding = "55px";
            paddingBottom = "110px";
            fontSize = "30px";
            fontFamily = "微软雅黑";
            lineHeight = "40px";
            background = "#D1D1D1";
            borderRadius = "12px";
        }
    
        msg.innerHTML = msgContent || "空";
        box.appendChild(msg);
        document.body.appendChild(box);
    }
    
    showMsg("内容")
    

    按键

    $("#textinput").keydown(function(e) {
        e.keyCode; // this value
    });

      

  • 相关阅读:
    Java进阶知识查漏补缺06
    SQL学习记录(concat)
    Restful API学习
    git学习
    获得xmlhttp对象
    vue-cli初接触
    vue初接触
    java使用百度UNIT
    JSON学习
    通用Mapper警告:建议修改基本类型为对应的包装类型!
  • 原文地址:https://www.cnblogs.com/cbw7172002/p/9164184.html
Copyright © 2020-2023  润新知