zoukankan      html  css  js  c++  java
  • BOM

    • document

        forms、images、links

    • location

        href、reload()

    • history

        go(-1)  ==  back()

        go(1)  ==  forward()

    • navigator
    • screen
    • frames
    • open

      alert  confirm  prompt

      setInterval  clearInterval  setTimeout  clearTimeout(用于setTimeout还没执行前调用)

     //取消默认的浏览器自带右键 很重要!!  
    
    window.oncontextmenu=function(e){
      e.preventDefault();
    })



    decodeURIComponent

    encodeURIComponent 

    Screen

    ①. 浏览器宽高(除window的任务栏)

     screen.availWidth,screen.availHeight

    ②.电脑宽高

     screen.width,screen.height


    #获取操作系统名

    function getOS() {
        // 苹果系统
        let isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
        if (isMac) return "Mac";
        // unix系统
        let isUnix = (navigator.platform == "X11") && !isWin && !isMac;
        if (isUnix) return "Unix";
        // Linux系统
        let isLinux = (String(navigator.platform).indexOf("Linux") > -1);
        if (isLinux) return "Linux";
        // window系统
        let sUserAgent = navigator.userAgent;
        let isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
        if (isWin) {
            let isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 || sUserAgent.indexOf("Windows 2000") > -1;
            if (isWin2K) return "Win2000";//win200
            let isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 || sUserAgent.indexOf("Windows XP") > -1;
            if (isWinXP) return "WinXP";//winxp
            let isWin2003 = sUserAgent.indexOf("Windows NT 5.2") > -1 || sUserAgent.indexOf("Windows 2003") > -1;
            if (isWin2003) return "Win2003";//win2003
            let isWinVista= sUserAgent.indexOf("Windows NT 6.0") > -1 || sUserAgent.indexOf("Windows Vista") > -1;
            if (isWinVista) return "WinVista";//winVista
            let isWin7 = sUserAgent.indexOf("Windows NT 6.1") > -1 || sUserAgent.indexOf("Windows 7") > -1;
            if (isWin7) return "Win7";//win7
            let isWin10 = sUserAgent.indexOf("Windows NT 10") > -1 || sUserAgent.indexOf("Windows 10") > -1;
            if (isWin10) return "Win10";//win10
        }
        return "other";
    }
    console.log('navigator.platform: ' + navigator.platform);
    console.log('navigator.userAgent: ' + navigator.userAgent);
    console.log("您的操作系统是:" + getOS());
    

    #获取浏览器名 

    function getBrower () {
      let browser = {};
      let userAgent = navigator.userAgent.toLowerCase();
      let s;
      (s = userAgent.match(/msie ([d.]+)/)) ? browser.ie = s[1] : (s = userAgent.match(/firefox/([d.]+)/)) ? browser.firefox = s[1] : (s = userAgent.match(/chrome/([d.]+)/)) ? browser.chrome = s[1] : (s = userAgent.match(/opera.([d.]+)/)) ? browser.opera = s[1] : (s = userAgent.match(/version/([d.]+).*safari/)) ? browser.safari = s[1] : 0;
      let version = "";
      if (browser.ie) {
        version = 'IE ' + browser.ie;
      }
      else {
        if (browser.firefox) {
          version = 'firefox ' + browser.firefox;
        }
        else {
          if (browser.chrome) {
            version = 'chrome ' + browser.chrome;
          }
          else {
            if (browser.opera) {
              version = 'opera ' + browser.opera;
            }
            else {
              if (browser.safari) {
                version = 'safari ' + browser.safari;
              }
              else {
                version = '未知浏览器';
              }
            }
          }
        }
      }
      return version;
    }
    console.log(getBrower());
    

     #获取ip地址

    <script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
    <script> 
      console.log(returnCitySN["cip"]+','+returnCitySN["cname"]) 
    </script>
    

      

    防止默认行为(表单提交按钮后页面刷新问题)

    e.preventDefault();

     

    1.鼠标事件以及clientX、offsetX、screenX、pageX、x的区别
    https://blog.csdn.net/weixin_41342585/article/details/80659736

    2.touch事件中的touches、targetTouches和changedTouches详解
    https://blog.csdn.net/ranran125/article/details/79747290

      

  • 相关阅读:
    Android开源项目收藏
    ubuntu修改ip获取方式(静态,动态)
    linux内核调用用户空间程序
    linux 改变目录下所有文件及其子文件夹下的权限
    jquery remove() empty()
    jquery之attr()和removeAttr() prop的使用场所
    jquery 获取对象的八种总结
    html子标签浮动父标签无法扩充
    静态代码块
    java static介绍
  • 原文地址:https://www.cnblogs.com/lgyong/p/8998944.html
Copyright © 2011-2022 走看看