开始阅读prototype1.5(参照9esuLuciano blog的注释和自己的理解)第一天

来源:互联网 发布:数据挖掘分类常用方法 编辑:程序博客网 时间:2024/06/06 17:46
 
  1. /*  Prototype JavaScript framework, version 1.5.1.1  
  2.  *  (c) 2005-2007 Sam Stephenson  
  3.  *  
  4.  *  Prototype is freely distributable under the terms of an MIT-style license.  
  5.  *  For details, see the Prototype web site: http://www.prototypejs.org/  
  6.  *  
  7. /*--------------------------------------------------------------------------*/  
  8.   
  9. /*创建一个prototype对象,包含当前Prototype的版本以及当前浏览器信息*/  
  10. /*var prototype{}来创建对象,version:‘1.5.1.1’对象的属性创建*/
  11. var Prototype = {   
  12.   Version: '1.5.1.1',   
  13.   
  14. /*这个方法用的很巧,将一个NaN或者undefined对象通过两次!运算,得到false*/  
  15.   Browser: {   
  16.     IE:     !!(window.attachEvent && !window.opera),   
  17.     Opera:  !!window.opera,   
  18.     WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,   
  19.     Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1   
  20.   },   
  21. /*IE6.0和Firefox2.0都不支持XPath*/  
  22. /*IE6.0不支持ElementExtensions,Firefox则支持*/  
  23.   BrowserFeatures: {   
  24.     XPath: !!document.evaluate,   
  25.     ElementExtensions: !!window.HTMLElement,   
  26.     SpecificElementExtensions:   
  27.       (document.createElement('div').__proto__ !==   
  28.        document.createElement('form').__proto__)   
  29.   },   
  30.   
  31. /*正则,用来抽取出页面上用<script ...> ... </script>标记的代码段*/  
  32.   ScriptFragment: '<script[^>]*>([//S//s]*?)<//script>',   
  33.   JSONFilter: /^///*-secure-([/s/S]*)/*///s*$/,   
  34.   
  35. /*定义一个空函数*/  
  36.   emptyFunction: function() { },   
  37. /*暂时不明白定义这个函数的用意*/  
  38.   K: function(x) { return x }   
  39. }   
原创粉丝点击