• 常用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
    });

      

  • 相关阅读:
    poj3660 最短路/拓扑序
    poj1502 最短路
    poj3259 最短路判环
    poj1680 最短路判环
    一些自己常用的cdn
    bower
    vuejs点滴
    jquery的ajax
    jquery点滴
    githubpage+hexo构建自己的个人博客
  • 原文地址:https://www.cnblogs.com/cbw7172002/p/9164184.html
Copyright © 2020-2023  润新知