澳门新浦京娱乐场网站-www.146.net-新浦京娱乐场官网
做最好的网站

澳门新浦京娱乐场网站:Pre0小抄本_javascript手艺

Prototype1.5.0_rc1: 源代码: //www.jb51.net/tools/prototype/prototype1.5.0_rc1.js Prototype1.5.0Pre0小抄本: 1280x960: //www.jb51.net/tools/prototype/prototype1280.png 1280x960: //www.jb51.net/tools/prototype/prototype1280w.png14400x900: //www.jb51.net/tools/prototype/prototype1440.png 14400x900: //www.jb51.net/tools/prototype/prototype1440w.png

环境:
Prototype Version: '1.6.1_rc3'
Aptana Studio, build: 1.2.5.023247
IE7
FF2.0.0.4
Opera 10 beta

环境: Prototype Version: '1.6.1_rc3' Aptana Studio, build: 1.2.5.023247 IE7 FF2.0.0.4 Opera 10 beta 复制代码 代码如下:var Prototype = { Version: '1.6.1_rc3', //定义浏览器对象 Browser: { var ua = navigator.userAgent; var isOpera = Object.prototype.toString.call == '[object Opera]'; return { IE: 澳门新浦京娱乐场网站:Pre0小抄本_javascript手艺_脚本之家,Prototype对象_prototype_脚本之家。!!window.attachEvent && !isOpera, Opera: isOpera, WebKit: ua.indexOf > -1, Gecko: ua.indexOf > -1 && ua.indexOf === -1, MobileSafari: /Apple.*Mobile.*Safari/.test, //定义浏览器Feature对象 BrowserFeatures: { XPath: !!document.evaluate, SelectorsAPI: !!document.querySelector, ElementExtensions: { var constructor = window.Element || window.HTMLElement; return !!(constructor && constructor.prototype); })(), SpecificElementExtensions: { if (typeof window.HTMLDivElement !== 'undefined') return true; var div = document.createElement; var form = document.createElement; var isSupported = false; if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) { isSupported = true; } div = form = null; return isSupported; })() }, ScriptFragment: '

from Ajax中国

复制代码 代码如下:

Prototype 1.5.0_rc2 版本一周前早已揭露了。十分低调,外国的网址也从未怎么情形,看来大家都筹备着过圣诞呢。

var Prototype = {
Version: '1.6.1_rc3',
//定义浏览器对象
Browser: (function(){
var ua = navigator.userAgent;
var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
return {
IE: !!window.attachEvent && !isOpera,
Opera: isOpera,
WebKit: ua.indexOf('AppleWebKit/') > -1,
Gecko: ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -1,
MobileSafari: /Apple.*Mobile.*Safari/.test(ua)
}
})(),
//定义浏览器Feature对象
BrowserFeatures: {
XPath: !!document.evaluate,
SelectorsAPI: !!document.querySelector,
ElementExtensions: (function() {
var constructor = window.Element || window.HTMLElement;
return !!(constructor && constructor.prototype);
})(),
SpecificElementExtensions: (function() {
if (typeof window.HTMLDivElement !== 'undefined')
return true;
var div = document.createElement('div');
var form = document.createElement('form');
var isSupported = false;
if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) {
isSupported = true;
}
div = form = null;
return isSupported;
})()
},
ScriptFragment: '<script[^>]*>([\S\s]*?)</script>',
JSONFilter: /^/*-secure-([sS]*)*/s*$/,
emptyFunction: function() { },
K: function(x) { return x }
};
if (Prototype.Browser.MobileSafari)
Prototype.BrowserFeatures.SpecificElementExtensions = false;

rc2版本未有怎么首要的换代,以Bug修复和性质调优为主。小编以为值得后生可畏提的修正有:

Broswer对象是由此调用无名函数而且及时奉行的方法赶回的,实施无名氏函数的法子有二种:

  • $(卡塔尔 和 $$(卡塔尔国 函数的习性优化
  • XHENCORE扩充了越来越多调整及API优化。比如增添 encoding 选项设置;定义了分明的Accept HTTP头音讯;parameters 今后能够传递字符串大概hash对象作为参数等等。
  • Element.getStyle()今后能够精确的拿走float属性。因为float是JavaScript的保留字,所以在IE中float的脚本属性名是styleFloat,Firefox则为cssFloat,Opera两个都扶助。
  • 追加了String.prototype.underscore and String.prototype.dasherize 多少个措施,example:

    'Hello_World'.dasherize() -> 'Hello-World' 'borderBottomWidth'.underscore() -> 'border_bottom_width' 'borderBottomWidth'.underscore().dasherize() -> 'border-bottom-width'

  1. (function(卡塔尔(英语:State of Qatar){return 1}卡塔尔国(卡塔尔 //(卡塔尔国能够强逼求值,重回函数对象然后实践函数
  2. (function(卡塔尔(英语:State of Qatar){return 1}(卡塔尔卡塔尔(英语:State of Qatar) //重返函数试行的结果
  3. void function(卡塔尔国{alert(1卡塔尔(قطر‎}(卡塔尔国 //void 也是有免强运算的用法
    此中判断Opera的主意isOpera用到了window.opera,在Opera浏览器中会重临贰个目标,其余浏览器重返undefined
    BrowserFeatures对象首要剖断浏览器的有个别特点,FF扶助广大的风味在IE下不支持,举个例子document.evalute方法就能够通过XPATH的章程操作HTML文书档案,但IE就不扶助。
    此函数详细用法如下:

详细更新列表参见prototype的 CHANGELOG

复制代码 代码如下:

摩登版本的prototype能够从这里下载。

var xpathResult = document.evaluate(xpathExpression, contextNode, namespaceResolver, resultType, result);

The evaluate function takes a total of five arguments:
xpathExpression: A string containing an xpath expression to be evaluated
contextNode: A node in the document against which the Xpath expression should be evaluated
namespaceResolver: A function that takes a string containing a namespace prefix from the xpathExpression and returns a string containing the URI to which that prefix corresponds. This enables conversion between the prefixes used in the XPath expressions and the (possibly different) prefixes used in the document
resultType: A numeric constant indicating the type of result that is returned. These constants are avaliable in the global XPathResult object and are defined in the relevaant section of the XPath Spec. For most purposes it's OK to pass in XPathResult.ANY_TYPE which will cause the results of the Xpath expression to be returned as the most natural type
result:An existing XPathResult to use for the results. Passing null causes a new XPathResult to be created.
其中__proto__那个在FF下能够获取对象的prototype对象,即对象的原型。那也是javascript袭承机制的底工,基于原型的存在延续,不像日常的C ,JAVA,C#语言的遵照类的后续。还恐怕有生机勃勃种metaclass的接轨格局,在ruby和python中根本应用。
此中ScriptFragment定义网页中援用脚本的正则表达式
JSONFilter:还是引用prototype原作的疏解更明了他的用法——

复制代码 代码如下:

/*String#evalJSON internally calls String#unfilterJSON and automatically removes optional security comment delimiters (defined in Prototype.JSONFilter).*/

person = '/*-secure-n{"name": "Violet", "occupation": "character"}n*/'.evalJSON() person.name; //-> "Violet"

/*You should always set security comment delimiters (/*-secure-n...*/) around sensitive JSON or JavaScript data to prevent Hijacking. (See this PDF document for more details.)*/

Prototype.K正是回来第多个参数的艺术:

复制代码 代码如下:

Prototype.K('hello world!'); // -> 'hello world!'
Prototype.K(1.5); // -> 1.5
Prototype.K(Prototype.K); // -> Prototype.K

说Bellamy下JavaScript里面包车型地铁静态方法和实例方法
静态方法要这么扩充:
Date.toArray=function(){}
那么toArray方法便是Date的静态方法,不能够这么调用(new Date(卡塔尔国卡塔尔国.toArray(卡塔尔国;不然会抛出极度
要如此用:Date.toArray(卡塔尔国
实例方法要那样扩张:
Date.prototype.toArray2=function(){}
这正是说toArray2方法便是Date的实例方法了,不可能那样调用Date.toArray2(卡塔尔国;
要如此用:(new Date(卡塔尔(英语:State of Qatar)卡塔尔.toArray2(卡塔尔(英语:State of Qatar)

Prototype Version: '1.6.1_rc3' Aptana Studio, build: 1.2.5.023247 IE7 FF2.0.0.4 Opera 10 beta 复制代码 代码如下: var Prototype = { Version: '1.6.1_rc3', //定义浏览...

本文由澳门新浦京娱乐场网站发布于服务器,转载请注明出处:澳门新浦京娱乐场网站:Pre0小抄本_javascript手艺