<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script>
function a(){
alert('aa');
}
function b(){
alert('bb');
}
function callFunction(){
var functionName = document.getElementById('functionName').value;
//初始化this.func属性,
this.func = function(){};
try{
//这里用eval方法,把我们传进来的这个方法名所代表的方法当作一个对象来 赋值给callFunction的func属性。
this.func = eval(functionName);
}catch(e){
alert("找不到"+functionName+"()这个方法");
}
}
function call(){
var test = new callFunction();
test.func();
}
</script>
</head>
<body>
<input type ="text" id="functionName" />
<input type="button" value="调用这个方法" οnclick="call()" />
</body>
</html>