<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
function call(fun){
try{
if(typeof(eval(fun))=="function"){
try{
var str=fun+"('"+fun+"')";
eval(str);
}catch(e){
alert('函数'+fun+'定义错误');
}
}
}catch(e){
alert('函数'+fun+'未定义');
}
}
function aa(str){
alert(str+':aa被执行了')
}
function bb(str){
alert(str+':bb被执行了')
}
function cc(str){
alert(str+':cc被执行了')
}
</script>
</head>
<body>
请输入aa、bb、cc、dd 进行测试
<input type="text" id="funname"/><input type="button" value="测试" οnclick="call($('#funname').val())"/>
</body>
</html>
动态执行JS
最新推荐文章于 2023-07-19 14:05:34 发布