<!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="測試" onclick="call($('#funname').val())"/>
</body>
</html>
動態執行JS
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.