Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何检查原型是否已加载/包含在页面中?如果我检查“原型”对象并且未加载原型,则会在 firebug 中收到“未定义原型”错误。
http://jsfiddle.net/pampurio97/evRTx/
Usingtypeof将传递一个未声明/未定义的对象。
typeof
if ( typeof Prototype !== "undefined" ) { // ... }
我相信这稍微干净一些:
var Prototype = window.Prototype; if(Prototype) { //Prototype is loaded }