通过:
xmlhttp.onreadystatechange= function(){FuncName(param)};
or
xmlhttp.onreadystatechange= new Function("FuncName(param)");
就可以了。

 

<script type="text/javascript">
//直接通过XMLHttpRequest对象获取远程网页源代码
function getSource(site,action){
 if(action=="Baidu"){
  xmlHttp.onreadystatechange=writeBaidu;    //设置回调函数
  xmlHttp.open("POST", "../Get/js_baidu.asp", true);
 }
 if(action=="Google"){
  xmlHttp.onreadystatechange=writeGoogle;    //设置回调函数
  xmlHttp.open("POST", "../Get/js_google.asp", true);
 }
 if(action=="Alexa"){
  xmlHttp.onreadystatechange=function(){writeAlexa(site);};    //设置回调函数
  xmlHttp.open("POST", "../Get/js_alexa.asp", true);
 }
 if(action=="PageRank"){
  xmlHttp.onreadystatechange=writePageRank;    //设置回调函数
  xmlHttp.open("POST", "../Get/js_pr.asp", true);
 }
 xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
 xmlHttp.send("site=" + encodeURIComponent(site));  //发送包含地址信息的请求体
}

//将远程网页源代码写入页面文字区域
function writeBaidu(){
 if (xmlHttp.readyState==4){
  baiduSource=xmlHttp.responseText;
  
  var someText=baiduSource;
  var pattern=new RegExp(/找到相关结果数((.|\n)*?)个/);
  //var outCome_exec=pattern.exec(someText);
  //document.getElementById("Baidu").value=outCome_exec[1].replace(',','');
  var outCome_matc=someText.match(pattern);
  document.getElementById("Baidu").value=outCome_matc[1].replace(',','');
  
  document.getElementById("Tip_Baidu").innerHTML="<img src='/Images/ok.gif'>";
  
  getSource("<%=Link_Url%>","Google");
 }
}

//将远程网页源代码写入页面文字区域
function writeGoogle(){
 if (xmlHttp.readyState==4){
  var someText=xmlHttp.responseText;
  var pattern=new RegExp(/找到约 ((.|\n)*?) 条结果/);
  //var outCome_exec=pattern.exec(someText);
  //document.getElementById("Google").value=outCome_exec[1].replace(',','');
  var outCome_matc=someText.match(pattern);
  document.getElementById("Google").value=outCome_matc[1].replace(',','');
  
  document.getElementById("Tip_Google").innerHTML="<img src='/Images/ok.gif'>";
  
  getSource("<%=Link_Url%>","Alexa");
 }
}

//将远程网页源代码写入页面文字区域
function writeAlexa(site){
 if (xmlHttp.readyState==4){
  var strRegExp="<a href=\"\/siteinfo\/"+site+"#trafficstats\">\n((.|\n)*?)<\/a>"
  
  var someText=xmlHttp.responseText;
  var pattern=new RegExp(strRegExp);
  //var outCome_exec=pattern.exec(someText);
  //document.getElementById("Alexa").value=outCome_exec[1].replace(',','');
  var outCome_matc=someText.match(pattern);
  document.getElementById("Alexa").value=outCome_matc[1].replace(',','');
  
  document.getElementById("Tip_Alexa").innerHTML="<img src='/Images/ok.gif'>";
  
  getSource("<%=Link_Url%>","PageRank");
 }
}

//将远程网页源代码写入页面文字区域
function writePageRank(){
 if (xmlHttp.readyState==4){
  var someText=xmlHttp.responseText;
  
  document.getElementById("PageRank").value=someText;
  
  document.getElementById("Tip_PageRank").innerHTML="<img src='/Images/ok.gif'>";
  
  writeBaidu_Date("<%=Link_Url%>");
 }
}

//将远程网页源代码写入页面文字区域
function writeBaidu_Date(site){
 var strRegExp="<span class=\"g\">  www."+site+"\/ (\\d{4}-(\\d{2}|\\d{1})-(\\d{2}|\\d{1}))  <\/span>";
 
 var someText=baiduSource;
 var pattern=new RegExp(strRegExp);
 //var outCome_exec=pattern.exec(someText);
 //document.getElementById("Baidu_Date").value=outCome_exec[1].replace(' ','');
 var outCome_matc=someText.match(pattern);
 document.getElementById("Baidu_Date").value=outCome_matc[1].replace(' ','');
 
 document.getElementById("Tip_Baidu_Date").innerHTML="<img src='/Images/ok.gif'>";
}

//根据window.XMLHttpRequest对象是否存在使用不同的创建方式
if (window.XMLHttpRequest){
 xmlHttp=new XMLHttpRequest();     //FireFox、Opera等浏览器支持的创建方式
}
else{
 xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); //IE浏览器支持的创建方式
}

getSource("<%=Link_Url%>","Baidu");
</script>