还请注意如何执行页面上的js。例如,如果您执行以下操作:(function(window, document, undefined){ var foo = document.getElementById("foo"); console.log(foo);})(window, document, undefined); 这将返回null,因为您将在加载文档之前对其进行调用。更好的选择..(function(window, document, undefined){// code that should be taken care of right awaywindow.onload = init; function init(){ // the code to be called when the dom has loaded // #document has its nodes }})(window, document, undefined);