Prototype 源码 1
var Prototype = {
Version: "1.7.3",
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/.test(ua)
};
}
)(),
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"),
form = document.createElement("form"),
isSupported = false;
if ((div["__proto__"]) && ((div["__proto__"]) !== (form["__proto__"]))) {
isSupported = true;
}
div = form = null;
return isSupported;
}
)()
},
ScriptFragment: "<script[^>]*>([\\S\\s]*?)</script\\s*>",
JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
emptyFunction: function () {},
K: function (x) {
return x;
}
}
## 知识点更新:
### navigator 包含浏览器的信息。http://www.w3school.com.cn/jsref/dom_obj_navigator.asp
常见用法:navigator.userAgent 返回userAgent头部,
例如 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"
使用navigator.userAgent判断浏览器类型: http://blog.csdn.net/tivonalh/article/details/55511143
### 2.Object.prototype 属性
Object.prototype.toString() 返回一个表示该对象的字符串,是用来判断对象类型的。
这里不得不提typeof,typeof只能区分基本类型,Number,String,Boolean,Undefined,Object,
如果要区分对象,数组,函数,typeof就不再适用,此时Object.prototype.toString()就派上用场。
http://blog.csdn.net/icanlove/article/details/43702879
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/prototype
### 3.call apply bind 用法
http://www.cnblogs.com/coco1s/p/4833199.html
### 4.attachEvent
attachEvent——兼容:IE7、IE8;不兼容firefox、chrome、IE9、IE10、IE11、safari、opera
addEventListener——兼容:firefox、chrome、IE、safari、opera;不兼容IE7、IE8
https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget/addEventListener
### 5.document.querySelector
https://developer.mozilla.org/zh-CN/docs/Web/API/Document/querySelector
### HTMLElement 和 Element
window.HTMLElement 继承 Element,代表任何HTML元素

浙公网安备 33010602011771号