to 梅花雪,我把原码贴上来帮我看看。 // auto binding of events expect <controlName>_<eventName> function HTDW_eventImplemented(sEventName) { // check if we already have one scripted if (this[sEventName] == null) { // check for function with default name var testName = this.name + '_' + sEventName; if (eval ('typeof ' + testName) == 'function') this[sEventName] = eval(testName); } return this[sEventName] != null; } function HTDW_DataWindowClass(name, submitForm, actionField, contextField) { // if used in 4GL web, these will not be defined! if (arguments.length == 1) { submitForm = null; actionField = null; contextField = null; }
// auto binding of events expect <controlName>_<eventName>
function HTDW_eventImplemented(sEventName)
{
// check if we already have one scripted
if (this[sEventName] == null)
{
// check for function with default name
var testName = this.name + '_' + sEventName;
if (eval ('typeof ' + testName) == 'function')
this[sEventName] = eval(testName);
} return this[sEventName] != null;
}
function HTDW_DataWindowClass(name, submitForm, actionField, contextField)
{
// if used in 4GL web, these will not be defined!
if (arguments.length == 1)
{
submitForm = null;
actionField = null;
contextField = null;
}
this.name = name;
this.submitForm = submitForm;
this.actionField = actionField;
this.contextField = contextField;
this.sortString = null;
this.action = "";
// private functions
this.buttonPress = HTDW_buttonPress;
this.performAction = HTDW_performAction; this.eventImplemented = HTDW_eventImplemented;
this.itemClicked = HTDW_itemClicked;
}
<SCRIPT LANGUAGE="JavaScript">
function mm(str)
{
this.name = str;
this.a = "aaa";
this["b"] = "bbb"; //这句与上面一句代码是等效的, 都是指定 mm 类的某个属性值
}
var m = new mm("meizz");
alert("m.name = "+ m.name);
alert("m.a = "+ m.a);
alert("m.b = "+ m.b);
</SCRIPT>
function mm(str)
{
this.a = "aaa";
var str = "b";
this[str] = "bbb"; //这里的属性名称可以用一个变量的值来代替了
}
if (eval ('typeof ' + testName) == 'function')
this[sEventName] = eval(testName);
}
eval ('typeof ' + testName) == 'function'这一句是判断this.name_sEventName是不是一个函数。
this.[sEventName]=eval(testName)这一句意思是如果testName是一个函数就把它指定给this[sEventName]吗
function gouzi(str)
{
alert("传进来的字符串是 = "+ str);
}
function mm(str)
{
this.name = str;
this.a = "aaa";
var str = "b";
this[str] = "bbb";
if(eval("typeof "+ "gouzi")=="function") //判断 gouzi 是否为一函数
this.func = eval("gouzi"); //this.func 是一个方法, 具体定义就是函数 gouzi
}
var m = new mm("meizz");
//alert("m.name = "+ m.name);
//alert("m.a = "+ m.a);
//alert("m.b = "+ m.b);
m.func("gooooooooooouzi");
</SCRIPT>