用正则表达式分离脚本和其他内容
//用正则表达式分离脚本和其他内容function addfriend(url) { $("loading").style.display="block"; var http=new ajax(); http.onreadystatechange=function () { if(ajax_returnresponse(http)) { var resTexthttp.responseText;var reg = /<script[^>]*>((.|\n)+)<\/script>/i;var match=resText.match(reg);var MyScript="";if(match!=null) //有脚本返回{ MyScript=match[1]; eval(MyScript);//执行脚本}var Html=resText.replace(reg,"");//获取不包含脚本的其他内容$("loading").innerHTML=Html; info(); return false; } }