zoukankan      html  css  js  c++  java
  • notenice trick

    Object.prototype.getType = function () {
      var ctor = this.constructor;
      if (typeof (ctor) != 'function') return;
      var reg = new RegExp(/function\ ([\w\$\_][\w\$\_\d]*)\(.*/gmi);
      var matches = reg.exec(ctor.toString());    
      return (matches[1]);  
    };
    /* above for core javscript */
    /* the following are for the core and the client, *not*  stable! */
    var Node = {};
    Node.ELEMENT_NODE = 1;          // Element
    Node.ATTRIBUTE_NODE = 2;        // Attr
    Node.TEXT_NODE = 3;             // Text
    Node.COMMENT_NODE = 8;          // Comment
    Node.DOCUMENT_NODE = 9;         // Document
    Node.DOCUMENT_FRAGMENT_NODE=11; // DocumentFragment 
    
    getType = function (obj){
      if (obj.navigator){
        return 'Window';
      }
      else if (obj.write){
        return 'Document';
      }
      else if(obj.tagName){
        var ret = obj.tagName;
        if (ret == 'INPUT' || ret == 'SELECT'){
          ret += ' ' + obj.type;
        }
        return ret;
      }
      else if(obj.nodeType){
        switch(obj.nodeType){
          case Node.ELEMENT_NODE:
            return obj.nodeName;
          case Node.ATTRIBUTE_NODE:
            return 'Attr';
          case Node.TEXT_NODE:
            return 'Text';
          case Node.COMMENT_NODE:
            return 'Comment'
          case Node.DOCUMENT_FRAGMENT_NODE:
            return 'DocumentFragment'
          default:
        }
      }
      else if (obj.constructor) {
        return obj.getType();    
      }
    };
    
  • 相关阅读:
    给C盘瘦身的秘诀
    电化学词汇大全
    Scrapy学习-(1)
    数学部分分支关系总结,有修改的欢迎留言。
    BindingException: Mapper method 'xxx.dao.StudentDao.insertStudent' attempted to return null from a method with a primitive return type (int).
    insertSale attempted to return null from a method with a primitive return type (int).
    Maven [ERROR] 不再支持源选项 5。请使用 7 或更高版本
    Python中字符串型数组--转换为-->数字型数组
    18、pywintypes.com_error: (-2147221008, '尚未调用 coinitialize。', none, none)
    17、ModuleNotFoundError: No module named 'pywin32_bootstrap'
  • 原文地址:https://www.cnblogs.com/qinghao/p/1676702.html
Copyright © 2011-2022 走看看