EXT在页面加载完后掉用函数显示窗口 function showWindow(){
var win = new Ext.Window({
width:400,
height:500,
title:"My Ext Window"
});
win.show();
}
Ext.onReady(showWindow); 为什么onReady调用showWindow没有括号,为什么下面就不行 Ext.onReady(showWindow());以前一般用下面的方法调用 Ext.onReady(function(){
showWindow();
});
这里为什么又有括号?
var win = new Ext.Window({
width:400,
height:500,
title:"My Ext Window"
});
win.show();
}
Ext.onReady(showWindow); 为什么onReady调用showWindow没有括号,为什么下面就不行 Ext.onReady(showWindow());以前一般用下面的方法调用 Ext.onReady(function(){
showWindow();
});
这里为什么又有括号?
解决方案 »
- 点击一个按钮增加一个DIV样式 这个怎么做?
- IE能不能通过js判断文件下载成功?
- 采集网页上的图片
- javascript中查询
- JS中对精确到秒的时间比较
- 在JS中函数参数的地址引用如何表示?
- 请教:怎样用js读取前页提交过来的form数据和地址栏参数?
- 我这个SHELL排序为什么不灵?
- 叶面用iframe包含了一个不同域名下的叶面。在这个被包含的叶面写了onload="window.parent.document.all('iframename').height=120",结果
- :BrentIvan(Ivan) 在吗 我按你的做了,不知为什么不显示页面了
- 完美下拉选择城市列表
- 如何在子页面里获取所在父页面的IFrame对象
if(docReadyState){
docReadyEvent.addListener(fn, scope, options);
docReadyEvent.fire();
docReadyEvent.clearListeners();
return;
}
if(!docReadyEvent){
initDocReady();
}
docReadyEvent.addListener(fn, scope, options);
},这是他的源码 相关函数体在这就不给楼主展现了 你可以在Ext-all.js中看 fn就是你的入口函数 他是一个函数名 而不是函数()
showWindow();
}); 这样写 里边的function(){ showWindow() } 这是一个匿名函数 与单纯的showWindow等价不知我这3楼的回复可让楼主满意否?
/**
* Adds new listener to be executed when all required scripts are fully loaded.
*
* @param {Function} fn The function callback to be executed
* @param {Object} scope The execution scope (`this`) of the callback function
* @param {Boolean} withDomReady Whether or not to wait for document dom ready as well
*/
onReady: function(fn, scope, withDomReady, options) {
var oldFn; if (withDomReady !== false && Ext.onDocumentReady) {
oldFn = fn; fn = function() {
Ext.onDocumentReady(oldFn, scope, options);
};
} if (!this.isLoading) {
fn.call(scope);
}
else {
this.readyListeners.push({
fn: fn,
scope: scope
});
}
},这是extjs 4.0.2a的onReady源码。里面写得很清楚了。
param {Function} fn The function callback to be executed(fn 一个能被执行的回调函数)。
注意了,是能被执行的,而不已经执行了的。楼主你的是已经执行了的。